I\'m trying to use a covariant type parameter inside a trait to construct a case-class like so:
trait MyTrait[+T] {
private case class MyClass(c: T)
}
Almost there. Here:
scala> trait MyTrait[+T] {
| private case class MyClass[U >: T](c: U)
| }
defined trait MyTrait
Which means MyClass[Any]
is valid for all T
. That is at the root of why one cannot use T
in that position, but demonstrating it requires more code than I'm in the mood for at the moment. :-)