You need to think about what contravariance means. That is, what does it imply and what constraints will result because of it. Hence,
trait Foo[-T]{
def stuff(t: T): T
}
Now think about what this means in the following context:
def action(that: Foo[Int]) = that.stuff(1)
and if I pass it a Foo[Any]
. Does this then mean that if I expect the following definition to hand me back an Int
that it will suceed?
def action(that: Foo[Int]): Int = that.stuff(1)
It can't, can it? That's because what you've defined is a function and functions have as their signature Function[-T, +R]
and you're trying to define it as Function[-T, -T]
.