-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Pattern Matching : Wrong Unreachable case warning #17188
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
This also happens for value match
case v: Double => ...
case v: Float => ...
... |
Hello jp, Code below does not raise any warning. [ neither in 3.2.2 nor in 3.3.0-RC3 ] def tell(value:AnyVal) =
value match
case d:Double => "Double"
case f:Float => "Float"
tell(1.0:Float) // -> "Float"
tell(1.0:Double) // -> "Double" |
@dwijnand do you think this could be appropriate for a spree? |
Yes. It's not going to be super interesting, it's a difference in typing |
This issue was picked for the Issue Spree No. 31 of 30 May 2023 which takes place in 2 days. @natsukagami, @eugenefle, @nmcb, @jan-pieter will be working on it. If you have any insight into the issue or guidance on how to fix it, please leave it here. |
To give some more detail, when typing the method |
Another attempt at minimization: sealed trait Bar:
val of : Any
trait A extends Bar
object B extends Bar:
val of : Int = 1
type Baz = Bar { val of : Int }
val x : Baz = ???
val y = x match
case B => B.of
case _ => 0 // unreachable It seems that when we are checking the possible remaining values of |
Compiler version
3.2.2, 3.3.0-RC3 , 3.3.1
Minimized code
https://scastie.scala-lang.org/vLKPswdSQgOT2z292wXTdg
Output
Expectation
The case is reachable.
Notes:
trait Bar
is not sealed, the faulty warning disappearstrait Baz extends Bar
is not present, the faulty warning disappears.The text was updated successfully, but these errors were encountered: