Closed
Description
In the following:
case class CC2[A, B](_1: A, _2: B)
object Test {
def main(args: Array[String]): Unit = {
val CC2(_, CC2(a, _)) = CC2(0, CC2(1, 2))
assert(a == 1)
}
}
a
type is inferred to Nothing
which leads to a ClassCastException (it's also caught by Ycheck).
The issue might be related to name base pattern matching given that this example work as expected using Tuple2
instead of CC2
.
Edit: Looks like a variance thing actually, type are inferred as expected with a covariant CC2
.