Skip to content

Type test on value of union type containing a primitive type is incorrectly reported as never succeeding #9736

Closed
@aappddeevv

Description

@aappddeevv

Minimized code

I noticed that type alias expansion does not happen prior to other stage (I'm not 100% I know what I am talking about).

type MyCombo = Int | Unit
val z: MyCombo = 10
z match
  case i: Int => ???
  case _ => ???

that this does not compile. If do val z: Int|Unit = 10 it does. Other than type ascription for z on the match, is there a better way to do this now with dotty?

Output

[error] -- Error: /home/me/proj/dotty-scalajs/src/main/scala/main.scala:31:13 --
[error] 31 |        case i:Int => i+10
[error]    |             ^
[error]    |this case is unreachable since type test1.MyCombo and class Integer are unrelated
[error] one error found
[error] (Compile / compileIncremental) Compilation failed

Expectation

Type alias would be expanded/evaluated so that the match would work.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions