Skip to content

Matching Over Unions With Primitive Type Problem #8781

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
odersky opened this issue Apr 23, 2020 · 0 comments · Fixed by #8788
Closed

Matching Over Unions With Primitive Type Problem #8781

odersky opened this issue Apr 23, 2020 · 0 comments · Fixed by #8788
Assignees

Comments

@odersky
Copy link
Contributor

odersky commented Apr 23, 2020

Minimized example

object test:

  val x: Int | String = 1

  x match
    case _: Int =>
    case _: String =>

Output

-- Error: i8779.scala:6:9 ------------------------------------------------------
6 |    case _: Int =>
  |         ^
  |this case is unreachable since type Int | String is not a subclass of class Integer

Expectation

Should compile.

@liufengyun liufengyun self-assigned this Apr 23, 2020
liufengyun added a commit to dotty-staging/dotty that referenced this issue Apr 24, 2020
liufengyun added a commit to dotty-staging/dotty that referenced this issue Apr 24, 2020
smarter added a commit that referenced this issue Apr 24, 2020
Fix #8781: handle union of primitive types in type test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants