Skip to content

Instantly share code, notes, and snippets.

@teamon
Last active December 18, 2015 02:48
Show Gist options
  • Save teamon/5713455 to your computer and use it in GitHub Desktop.
Save teamon/5713455 to your computer and use it in GitHub Desktop.
class A
class B extends A
class C extends B
class Foo[X] {
def x[T >: X] = 1
def y[T <: X] = 2
}
val foo = new Foo[B]
foo.x[A] // => OK
foo.x[B] // => OK
foo.x[C]
// <console>:13: error: type arguments [C] do not conform to method x's type parameter bounds [T >: B]
// foo.x[C]
// ^
foo.y[A]
// <console>:12: error: type arguments [A] do not conform to method y's type parameter bounds [T <: B]
// foo.y[A]
// ^
foo.y[B] // => OK
foo.y[C] // => OK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment