Open
Description
Was: Match type reduction fails in suspicious way when enumerations are involved
Compiler version
3.4.0, 3.3.2
Minimized code
https://scastie.scala-lang.org/0x9CDEHuQlG6P5ABf9899g
enum A:
case B
case C
case D
object A:
type B = B.type
type C = C.type
type D = D.type
given A = A.B
type Matcher[T] = T match
case A.C.type | A.D.type => Int
case A.B.type => Float
def fn[U <: A](using U)(value: Matcher[U]): Matcher[U] = value
val x = summon[A] match
case given (A.C | A.D) => fn(5)
case given A.B => fn(5f)
val y = summon[A] match
case given (A.C.type | A.D.type) => fn(5) //compiler error about cannot prove disjoint
case given A.B.type => fn(5f) //compiler error about cannot prove disjoint
Output
trying to reduce Playground.Matcher[Playground.A]
failed since selector Playground.A
does not match case (Playground.A.C : Playground.A) | (Playground.A.D : Playground.A) => Int
and cannot be shown to be disjoint from it either.
Therefore, reduction cannot advance to the remaining case
Expectation
This should be fine, since A, B, C, and D are all sealed. The union type isn't the problem either because removing it still has the bottom two cases giving compile time errors (and of course the first case on x
as well).