Closed tindzk closed 6 years ago
The error message here is unhelpful, but I'm not entirely sure I understand why this should compile. Notice that your minimised example fails in exactly the same way with Lightbend Scala, as I think it should.
Indeed. The following example would fail as well:
case class MyList[T <: String]()
def f[T](value: T): Unit = {}
f(null.asInstanceOf[MyList[_]])
I agree that the error message should be more comprehensible. The problem can be fixed by taking Any
instead of T
. However, I do not understand yet why wildcards cannot be used in conjunction with type parameter bounds.
The other issue where the value cannot be printed seems to be a bug in Ammonite.
I'm closing this because it doesn't appear to be a TLS-specific problem.
It is possible to instantiate a singleton type parameter with a wildcard, but not print it:
Edit: Here is a minimised example:
The error occurs whenever
Wrap[_]
is passed as a function argument.