Open
Description
Consider the following example:
case class MyList[T <: String]()
def f[T](value: T): Unit = {}
f(null.asInstanceOf[MyList[_]])
It fails with the following error:
error: type arguments [_$1] do not conform to class MyList's type parameter bounds [T <: String]
f(null.asInstanceOf[MyList[_]])
However, the above example does work when either
- explicitly passing the type:
f[MyList[_]](null)
, or - defining the function as
def f(value: Any): Unit = {}
.
I am not entirely sure whether this is the intended behaviour. In any case, it would be helpful to issue a better error message.
See also com-lihaoyi/Ammonite#629 and typelevel/scala#156.