Skip to content

Spurious pattern exhaustivity warning when one type parameter lower-bounds another #15523

Closed
@OlivierBlanvillain

Description

@OlivierBlanvillain

This example:

sealed trait Parent
final case class Leaf[A, B >: A](a: A, b: B) extends Parent

def run(x: Parent): Unit = x match {
  case Leaf(a, b) =>
}

Leads to the following spurious warning:

-- [E029] Pattern Match Exhaustivity Warning:
6 |def run(x: Parent): Unit = x match {
  |                           ^
  |                           match may not be exhaustive.
  |
  |                           It would fail on pattern case: Leaf(_, _)
  |
  | longer explanation available when compiling with `-explain`
1 warning found

I suspect the issue to be different from #15522, since it is present on both main and 3.1.2.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions