Skip to content

Enum Value singleton fails to reduce in match type #10511

Closed
@bishabosha

Description

@bishabosha

Minimised Code

enum Bool {
  case True
  case False
}

import Bool._

type Not[B <: Bool] = B match {
  case True.type => False.type
  case False.type => True.type  
}

val f: Not[False.type] = True

Output

13 |val f: Not[False.type] = True
   |                         ^^^^
   |                         Found:    (Bool.True : Bool)
   |                         Required: Not[(Bool.False : Bool)]

Expectation

if I replace enum Bool with a sealed trait and case objects then the code compiles:

+sealed trait Bool
+object Bool {
+  case object True extends Bool
+  case object False extends Bool
-enum Bool {
-  case True
-  case False
 }
...

Originally posted by @bishabosha in #10510 (comment)

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions