I had a (looong) version of this problem posted yesterday here: Trouble with type variance
To cut the (really) long story short, this:
class A[-P, T <: P]
does not compile (it complains, that "P occurs in covariant position in type <: P of type T").
An answer to my earlier question suggested that the declaration is indeed invalid, because A[Foo, Bar]
would be a subclass of A[Nothing, Bar]
, but the latter is illegal (Bar
isn't a subclass of Nothing
).
I don't think that's reason enough. By that logic, something like this should be illegal too: class B[+T <: String]
- B[String]
should be a subclass of B[Any]
but the latter is invalid.
Moreover, this:
class C[T, -P >: T]
Actually does compile. Isn't this essentially the same exact thing as A
above?