Skip to content

Binding name to sequence wildcard induces exhaustivity warning #8757

Closed
@som-snytt

Description

@som-snytt

Minimized code

scala> sealed trait T ; case class C(x: Int) extends T
// defined trait T
// defined case class C

scala> (C(42): T) match { case C(42) => }
1 |(C(42): T) match { case C(42) => }
  | ^^^^^^^^
  | match may not be exhaustive.
  |
  | It would fail on pattern case: C(_)

scala> (C(42): T) match { case C(_) => }

scala> (C(42): T) match { case C(x) => }

scala> sealed trait T ; case class C(x: Int*) extends T
// defined trait T
// defined case class C

scala> (C(42): T) match { case C(42) => }
1 |(C(42): T) match { case C(42) => }
  | ^^^^^^^^
  | match may not be exhaustive.
  |
  | It would fail on pattern case: C(_, _: _*), C(_, _, _: _*), C()

scala> (C(42): T) match { case C(xs: _*) => }
1 |(C(42): T) match { case C(xs: _*) => }
  | ^^^^^^^^
  | match may not be exhaustive.
  |
  | It would fail on pattern case: C(_: _*)

scala> (C(42): T) match { case C(_: _*) => }

scala>                                                         

Output

scala> (C(42): T) match { case C(xs: _*) => }
1 |(C(42): T) match { case C(xs: _*) => }
  | ^^^^^^^^
  | match may not be exhaustive.
  |
  | It would fail on pattern case: C(_: _*)

Expectation

Expect case C(xs: _*) is as exhaustive as case C(_: _*).

Observed at #8715

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions