Skip to content

Simple GADT giving "match may not be exhaustive" #10085

Closed
@atennapel

Description

@atennapel

Minimized code

enum Bool:
  case True
  case False

import Bool._

enum SBool[B <: Bool]:
  case STrue extends SBool[True.type]
  case SFalse extends SBool[False.type]

import SBool._

def f(b: SBool[True.type]): Unit = b match
  case STrue => ()

https://scastie.scala-lang.org/sFyhkz0wRg2Uvtl9GE37dQ

Output

match may not be exhaustive.

It would fail on pattern case: SFalse

Expectation

I would expect f to be exhaustive because from the type parameter we can know that SFalse cannot occur. Is this a limitation of Dotty or a bug?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions