Skip to content

False exhaustivity warning when unapply return type is a tuple defined using *:  #22355

Open
@eejbyfeldt

Description

@eejbyfeldt

Compiler version

3.6.2

Minimized code

object Test {
  sealed trait Expr[T]

  case class Person(name: String, age: Int)
  object PP {
    def unapply(e: Expr[Person]): String *: Int *: EmptyTuple = ???
  }

  val expr: Expr[Person] = ???
  expr match {
    case PP(str, _) => ???
  }
}

Output

-- [E029] Pattern Match Exhaustivity Warning: scala3_bug.scala:10:2 
10 |  expr match {
   |  ^^^^
   |  match may not be exhaustive.
   |
   |  It would fail on pattern case: PP()
   |------------------------------------------------------------------------------------------
   | Explanation (enabled by `-explain`)
   |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   | There are several ways to make the match exhaustive:
   |  - Add missing cases as shown in the warning
   |  - If an extractor always return Some(...), write Some[X] for its return type
   |  - Add a case _ => ... at the end to match all remaining cases
    ------------------------------------------------------------------------------------------
1 warning found

Expectation

The code should compile without warnings.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions