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

Incorrect exhaustivity warning when using opaque types with constraint and enums #22513

Open
eejbyfeldt opened this issue Feb 4, 2025 · 0 comments
Labels
area:enums area:opaque-types area:pattern-matching area:reporting Error reporting including formatting, implicit suggestions, etc itype:bug

Comments

@eejbyfeldt
Copy link

Compiler version

3.6.3

Minimized code

opaque type R[T] <: T = T

object Test {
  enum E:
    case E(a: Int)

  val v: R[E] = ???
  v match
    case E.E(_) =>
}

Output

[warn] ./opaque_subtype.scala:8:3
[warn] match may not be exhaustive.
[warn] 
[warn] It would fail on pattern case: _: R[E]
[warn]   v match
[warn] 

Expectation

The code should compile without warnings.

Adding the case from the exhaustive warning like this

opaque type R[T] <: T = T

object Test {
  enum E:
    case E(a: Int)

  val v: R[E] = ???
  v match
    case E.E(_) =>
    case _: R[E] => 
}

also does not compile with

[warn] ./dev/eejbyfeldt/scala_playground/opaque_subtype.scala:10:10
[warn] Unreachable case
[warn]     case _: R[E] =>
[warn] 
@eejbyfeldt eejbyfeldt added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 4, 2025
@Gedochao Gedochao added area:pattern-matching area:enums area:opaque-types area:reporting Error reporting including formatting, implicit suggestions, etc and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:enums area:opaque-types area:pattern-matching area:reporting Error reporting including formatting, implicit suggestions, etc itype:bug
Projects
None yet
Development

No branches or pull requests

2 participants