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
unapplySeq silences all exhaustivity warnings #9232
Comments
Imported From: https://issues.scala-lang.org/browse/SI-9232?orig=1 |
Guillaume Martres (Smarter) said: def transformTree(tree: Tree): Any = tree match {
case Node1(_) => ???
} Also produces the warnings you'd expect: test2.scala:14: warning: match may not be exhaustive.
It would fail on the following input: Node2()
def transformTree(tree: Tree): Any = tree match {
^
one warning found Which is why I'm saying that having |
@retronym said: Guards similarly hamper analysis: object Test {
def noWarningHere(x: Option[Any]): Any = x match {
case Some(1) if "".isEmpty => ???
}
} |
Guillaume Martres (Smarter) said:
Oh, I knew that this happened with guard but not with extractors. I think that two things need to be done at least:
The warning is especially important because a type system is much more useful when it is reliable, it's hard to rely on the exhaustiveness checker because it's so easy to accidentally disable it. |
Richard Bradley (richard.bradley) said:
I agree. |
The following code compiles without any warning:
But if you uncomment
unapply
, you get:It'd be nice to give the same warnings when only
unapplySeq
is used, for example withList
.The text was updated successfully, but these errors were encountered: