You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Perhaps.unapply is statically known to always succeed, because its return type is Some.
Yet
scala>Option("hello") match {
|casePerhaps(Some(s)) => println(s)
| }
hello
scala>
doesn't produce any warnings, even though the match would fail on None; and
scala>List(Option("hello")) match {
|casePerhaps(Some(s)) :: t => println(s)
|casePerhaps(None ) :: t => ()
|caseNil=> ()
| }
<console>:13:warning: match may not be exhaustive.
It would fail on the following input: List(_)
List(Option("hello")) match {
^
hello
scala>
produces a warning, even though the match is exhaustive.
This would be useful to pattern match on data types that are not defined as ADTs (or their definition as ADT is not publicly visible), but can be converted to a pattern matchable type.
The text was updated successfully, but these errors were encountered:
Not a bug report, but a feature request.
It would be useful to preserve exhaustivity checking if the custom extractor is declared to return
Some
.Perhaps.unapply
is statically known to always succeed, because its return type isSome
.Yet
doesn't produce any warnings, even though the match would fail on
None
; andproduces a warning, even though the match is exhaustive.
This would be useful to pattern match on data types that are not defined as ADTs (or their definition as ADT is not publicly visible), but can be converted to a pattern matchable type.
The text was updated successfully, but these errors were encountered: