-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Labels
fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)patmat
Milestone
Description
reproduction steps
using any version of Scala
object SeqExtractor {
def unapplySeq(x: Int): Some[List[Int]] = Some(List(1))
}
1 match {
case SeqExtractor() => "zero"
case SeqExtractor(_) => "one"
case SeqExtractor(_, _, _*) => "two or more"
}
problem
SeqExtractor is irrefutable, and the three cases together are exhaustive, but we fail to recognize that.
note
Matching on List can work around that by matching on Cons or Nil exhaustively with
List(1) match {
case Nil => 0 // or List() due to rewrite
case head :: Nil => 1
case head :: second :: tail => 2
}
Spun out of #12240
Awethon
Metadata
Metadata
Assignees
Labels
fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)patmat