Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Text
Posted by: Pahay Ragh
Added: Oct 26, 2020 3:18 AM
Views: 12
Tags: no tags
  1. class Super
  2. class Sub extends Super
  3. class SubSub extends Sub
  4.  
  5. class UpperBound[A <:Super](val value:A)
  6.  
  7. val test10:UpperBound[Super] = new UpperBound(new Super)
  8. val test12:UpperBound[Sub] = new UpperBound(new Sub)
  9. val test112:UpperBound[SubSub] = new UpperBound(new SubSub)
  10.  
  11.  
  12. class LowerBound[A >:Super](val value:A)
  13. val test13:LowerBound[Super] = new LowerBound(new Super)
  14. val test14:LowerBound[Super] = new LowerBound(new Sub)
  15. val test114:LowerBound[Super] = new LowerBound(new SubSub)
  16.  
  17.  
  18.  
  19. class UpperBound[A <:Sub](val value:A)
  20.  
  21. //val test1 = new UpperBound(new Super)
  22. // Error:(9, 13) inferred type arguments [Super]
  23. // do not conform to class UpperBound's type parameter bounds [A <: Sub]
  24. val test2:UpperBound[Sub] = new UpperBound(new Sub)
  25. val test21:UpperBound[SubSub] = new UpperBound(new SubSub)
  26.  
  27.  
  28. class LowerBound[A >:Sub](val value:A)
  29. val test3:LowerBound[Super] = new LowerBound(new Super)
  30. val test4:LowerBound[Sub] = new LowerBound(new Sub)
  31. val test41:LowerBound[Sub] = new LowerBound(new SubSub)
  32.  
  33.  
  34. class UpperBound[A <:SubSub](val value:A)
  35.  
  36. //val test1 = new UpperBound(new Super)
  37. // Error:(9, 13) inferred type arguments [Super]
  38. // do not conform to class UpperBound's type parameter bounds [A <: Sub]
  39. //val test2 = new UpperBound(new Sub)
  40. val test21:UpperBound[SubSub] = new UpperBound(new SubSub)
  41.  
  42.  
  43. class LowerBound[A >:SubSub](val value:A)
  44. val test3:LowerBound[Super] = new LowerBound(new Super)
  45. val test4:LowerBound[Sub] = new LowerBound(new Sub)
  46. val test41:LowerBound[SubSub] = new LowerBound(new SubSub)