Skip to content

Incorrect non-exhaustivity warning in pattern matches #15289

Closed
@nrinaudo

Description

@nrinaudo

Compiler version

3.1.2

Minimized code

enum Foo[A, B]:
  case Bar[A]() extends Foo[A, A]

def doFoo[A](foo: Foo[A, String]): String = foo match
  case Foo.Bar() => "baz"

Output

[warn] -- [E029] Pattern Match Exhaustivity Warning: /path/to/gadt/src/main/scala/repro.scala:6:44 
[warn] 6 |def doFoo[A](foo: Foo[A, String]): String = foo match
[warn]   |                                            ^^^
[warn]   |                                  match may not be exhaustive.
[warn]   |
[warn]   |                                  It would fail on pattern case: Foo.Bar()

Expectation

I would expect this not to warn, since there's a clear case Foo.Bar() => ... statement.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions