2009/10/27 Vladimir Reshetnikov <
v.reshetnikov@...>:
> [...]
> I am curious why the following code is rejected by Scala compiler:
> ////////////////////////////
> trait A[-T, S <: T]
> ////////////////////////////
> [...]
Hello,
since T is contravariant and unbounded, you can always narrow its type
as you like but there is no guarantee that the type bound on S would
still be fulfilled then. The only possible solution would be to force
S = Nothing.
Depending on what you actually want to do, the solution could be as
simple as moving the type bound to the variant type parameter T, which
works just fine:
trait A[-T >: S, S]
Ciao,
Thomas
--
When C++ is your hammer, every problem looks like your thumb.