Closed
Description
Exhaustivity checking in pattern matching on union types within product types seems to be too restrictive. This might be caused or reinforced by indirection through type aliases as it does not happen for testee3
(see below).
Minimized code
dotty version 0.25.0-RC1
case object X; type X = X.type
case object Y; type Y = Y.type
type XorY = X | Y
val testee1: XorY = X
testee1 match {
case value: XorY => println(value)
}
val testee2: Tuple1[XorY] = Tuple1(X)
testee2 match {
case Tuple1(value: XorY) => println(value)
}
type IntOrString = Int | String
val testee3: Tuple1[IntOrString] = Tuple1(42)
testee3 match {
case Tuple1(value: IntOrString) => println(value)
}
Output
[warn] | testee2 match {
[warn] | ^^^^^^^
[warn] | match may not be exhaustive.
[warn] |
[warn] | It would fail on pattern case: (_)
[warn] one warning found
Expectation
The compiler should understand that the match must be exhaustive and not give a warning.