Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unreachable pattern match warning for type test of enum where case mixes in sealed trait #22032

Closed
bishabosha opened this issue Nov 26, 2024 · 2 comments
Labels
area:pattern-matching itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label

Comments

@bishabosha
Copy link
Member

bishabosha commented Nov 26, 2024

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

@bishabosha bishabosha added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label area:pattern-matching labels Nov 26, 2024
@sjrd
Copy link
Member

sjrd commented Nov 26, 2024

Duplicate of #21860, fixed by #21876?

@bishabosha
Copy link
Member Author

looks like it, well the nightly has fixed my original problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:pattern-matching itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label
Projects
None yet
Development

No branches or pull requests

2 participants