According to the documentation, C[_]
is a shorthand for [X] =>> C[X]
from Scala 3.2 onwards.
However, they don’t seem to behave identically:
trait B[T]
def foo[C[_] <: B[_], T]: C[T] = ???
def bar: Unit =
foo[[X] =>> B[X], Int]
foo[B[_], Int] // Error: Type argument B[?] does not conform to upper bound [_] =>> B[?]
It looks like B[_]
is still interpreted as B[?]
. However, that is not supposed to happen from Scala 3.2 onwards:
- In Scala 3.0, both
_
and?
are legal names for wildcards.- In Scala 3.1,
_
is deprecated in favor of?
as a name for a wildcard. A-rewrite
option is available to rewrite one to the other.- In Scala 3.2, the meaning of
_
changes from wildcard to placeholder for type parameter.
Am I missing something?
If not, is there a way to force proper behavior from the compiler, with some kind of “future” flag? These error messages are very confusing.