-
Notifications
You must be signed in to change notification settings - Fork 21
Vector.unapplySeq is refutable #12240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
If/when this is fixed, I would hope that a match statement like this would also be considered exhaustive Vector("test") match {
case Vector() => "empty"
case Vector(_) => "one"
case Vector(_, _, _*) => "two or more"
} which seems like a good alternative to using Vector("test") match {
case Vector() => "empty"
case _ +: Vector() => "one"
case _ +: _ +: _ => "two or more"
} |
I wonder if changing |
Uh oh!
There was an error while loading. Please reload this page.
reproduction steps
using Scala 2.13.4
problem
The match is totally exhaustive. Unfortunately, scalac doesn't know.
Vector.unapplySeq
seems to be using name-based pattern matching to return aSeqFactory.UnapplySeqWrapper
. But name-based pattern matching can't AFAIK provide irrefutable patterns, so the pattern ends up refutable, and the warning (with the somewhat odd counterexample) is emitted.The text was updated successfully, but these errors were encountered: