This is directly related to the fact that Option covariant and is actually required in order for the types to match.
class Foo(x: Int) object Bar entends Foo(0) def foo(t: Option[Foo]) = t contains (new Foo(2))
I can actually pass in the type Option[Bar.type] , and it will "work" because Bar is Foo , and the type of type constraint requires that it also accept types that are supertypes of parameterized type A
val res = foo(Some(Bar)) >> res0: Boolean = false
Note that the above actually calls contains in the instance of a Option[Bar.type] . Therefore, [A1 >: A] .
wheaties
source share