I am trying to understand my mistake in implementing generics. I have a trait which defines a method that returns a reference with an upper type bound of the trait. How ever a var reference to an implementation of the trait fails to type check with Expression of type Capability[Class] doesn't conform to expected type Capability[Trait]
Here is the code:
trait IAITask {
def taskTypeReference[T >: IAITask]: Capability[T]
}
object Tasks {
var Walk: Capability[Walk] = _
}
class Walk extends IAITask {
override def taskTypeReference[T >: IAITask]: Capability[IAITask] = Tasks.Walk //This line does not type check
}