Skip to content

Spurious exhaustivity warning using an irrefutable unapply with a singleton type #13110

Closed
@SrTobi

Description

@SrTobi

reproduction steps

minimized code:

object Test {
  sealed trait Base
  class Blub extends Base
  object Blub {
    def unapply(blub: Blub): Some[(Int, blub.type)] =
      Some(1 -> blub)
  }

  (null: Base) match {
    case Blub(i, x) => println(i)
  }
}

problem

Expect everything to compile without warnings, but gives

match may not be exhaustive.

It would fail on pattern case: Blub(_, _)

  (null: Base) match {

If the dependent type is removed or (null: Blub) used, the warning will go away

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions