Reputation: 2091
In over my head dealing with a tricky covariant type used in an inherited trait's overridden function. The basic question is, what is the [?]
type? I can't find a good definition (it's kinda ungooglable), and so it's unclear why a [T]
gets replaced with [?]
in the following example:
> sealed trait Bar[+T]
> trait FooT { type Other; def foo[T,V](stuff:Bar[T]*) { stuff.headOption.isDefined } }
> trait TooF extends FooT { override def foo[T,V](stuff:Bar[T]*) { super.foo(stuff) } }
<console>:7: error: type mismatch;
found : Bar[T]*
required: Bar[?]
trait TooF extends FooT { override def foo[T,V](stuff:Bar[T]*) { super.foo(stuff) } }
Upvotes: 0
Views: 111
Reputation: 36011
I'm not sure of the exact reason that it shows Bar[?]
but I think it probably something like the type parameter hasn't been resolved yet. The real problem is that your syntax for passing the varargs on to the super method is incorrect. It should be
override def foo[T,V](stuff:Bar[T]*) { super.foo(stuff:_*) }
Upvotes: 3