I have this mock example of a problem I am facing.
class Baz[-A](
) {
def p: Unit = println("hi")
}
def n[A](b: Baz[A]): Unit = b.p
trait Foo[R[_] <: Baz[_]] {
def m[A](req: R[A]): Unit = {
n(req)
}
}
I get this compile time error
no type parameters for method n: (b: Baz[A])Unit exist so that it can be applied to arguments (R[A])
--- because ---
argument expression's type is not compatible with formal parameter type;
found : R[A]
required: Baz[?A]
n(req)
I was expecting that because I have specified the super type for R[_] to be Baz[_] passing a value of type R[_] to a method that requires a Baz[A] would resolve but the compiler doesn't seem to think so. What am I not understanding here?
Ais notInt. Trydef m(req: R[Int])