Created
October 26, 2020 03:18
-
-
Save rupeshtr78/3c5c8784af1f44589d4702c7873b2480 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Super | |
class Sub extends Super | |
class SubSub extends Sub | |
class UpperBound[A <:Super](val value:A) | |
val test10:UpperBound[Super] = new UpperBound(new Super) | |
val test12:UpperBound[Sub] = new UpperBound(new Sub) | |
val test112:UpperBound[SubSub] = new UpperBound(new SubSub) | |
class LowerBound[A >:Super](val value:A) | |
val test13:LowerBound[Super] = new LowerBound(new Super) | |
val test14:LowerBound[Super] = new LowerBound(new Sub) | |
val test114:LowerBound[Super] = new LowerBound(new SubSub) | |
class UpperBound[A <:Sub](val value:A) | |
//val test1 = new UpperBound(new Super) | |
// Error:(9, 13) inferred type arguments [Super] | |
// do not conform to class UpperBound's type parameter bounds [A <: Sub] | |
val test2:UpperBound[Sub] = new UpperBound(new Sub) | |
val test21:UpperBound[SubSub] = new UpperBound(new SubSub) | |
class LowerBound[A >:Sub](val value:A) | |
val test3:LowerBound[Super] = new LowerBound(new Super) | |
val test4:LowerBound[Sub] = new LowerBound(new Sub) | |
val test41:LowerBound[Sub] = new LowerBound(new SubSub) | |
class UpperBound[A <:SubSub](val value:A) | |
//val test1 = new UpperBound(new Super) | |
// Error:(9, 13) inferred type arguments [Super] | |
// do not conform to class UpperBound's type parameter bounds [A <: Sub] | |
//val test2 = new UpperBound(new Sub) | |
val test21:UpperBound[SubSub] = new UpperBound(new SubSub) | |
class LowerBound[A >:SubSub](val value:A) | |
val test3:LowerBound[Super] = new LowerBound(new Super) | |
val test4:LowerBound[Sub] = new LowerBound(new Sub) | |
val test41:LowerBound[SubSub] = new LowerBound(new SubSub) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment