Skip to content

Exhaustivity checking false positive #9067

Closed
@travisbrown

Description

@travisbrown

Minimized code

sealed trait Base[A, +B]
case class Foo[A, +B](f: A => B) extends Base[A, B]

def bar(x: Base[Any, Any]): Unit = x match { case Foo(_) => }

Output

// defined trait Base
// defined case class Foo
4 |def bar(x: Base[Any, Any]): Unit = x match { case Foo(_) => }
  |                                   ^
  |                                   match may not be exhaustive.
  |
  |                                   It would fail on pattern case: Foo(_)
def bar(x: Base[Any, Any]): Unit

Expectation

This should compile without a warning, as it does in Scala 2 and Dotty up until at least 0.23.0. I first noticed it giving this warning in 0.24.0-RC1, but haven't tried to narrow it down beyond that.

I also haven't tried very to hard to minimize it further, but it might be worth noting that making B invariant, A concrete, or changing f: A => B to something like (A, B) all make the warning go away.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions