unreachable pattern match warning for type test of enum where case mixes in sealed trait #22032
Closed
Description
Compiler version
3.5.2, 3.6.2-RC1
Minimized code
sealed trait Decorated
enum Foo:
case A
case B extends Foo with Decorated
def decoratedFoo(a: Foo): Option[Decorated] =
Some(a).collect { case a: Decorated => a }
Output
1 warning found
-- [E030] Match case Unreachable Warning: --------------------------------------
1 |def decoratedFoo(a: Foo): Option[Decorated] = Some(a).collect { case a: Decorated => a }
| ^^^^^^^^^^^^
| Unreachable case
Expectation
I would think that the space analysis can realize that children of one sealed class can intersect with children of an otherwise "unrelated" sealed trait