Skip to content

Incorrect union type exhaustivity warning #12279

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

Closed
Swoorup opened this issue Apr 29, 2021 · 0 comments · Fixed by #12282
Closed

Incorrect union type exhaustivity warning #12279

Swoorup opened this issue Apr 29, 2021 · 0 comments · Fixed by #12282

Comments

@Swoorup
Copy link

Swoorup commented Apr 29, 2021

Compiler version

3.0.0-RC3

Minimized code

import scala.reflect.Typeable

def unionTypeTest[T: Typeable](m: Int|T) = 
  m match
    case x: Int => println("Got Int")
    case t: T => println("Got T")

@main def run = 
  unionTypeTest(())

Output

match may not be exhaustive.

It would fail on pattern case: _: T

Expectation

No warnings since the union type match pattern is exhaustive.

@Swoorup Swoorup changed the title Union type exhaustivity warning Incorrect union type exhaustivity warning Apr 29, 2021
liufengyun added a commit to dotty-staging/dotty that referenced this issue Apr 29, 2021
@liufengyun liufengyun self-assigned this Apr 29, 2021
liufengyun added a commit that referenced this issue Apr 30, 2021
michelou pushed a commit to michelou/scala3 that referenced this issue May 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants