-
Notifications
You must be signed in to change notification settings - Fork 1.1k
No static check for pattern match on Identifiers #9166
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
The code seems to be technically correct. |
Scala 2 compact issues are for those that scala 2 supports but scala 3.0 does not. Here it is the opposite. |
ok I guess it is a philosophical debate whether or not to allow a case that is a supertype because potentially it could match but maybe its a useless branch trait Trait
object UnitTest extends App {
val Foo: AnyRef = ""
def foo(m: Trait) = m match {
case Foo => println("ok")
}
foo(Foo)
} Scala 2 has the same behaviour here. |
That should not compile. There should be an error in |
Sorry yeah the confusion comes from if it is a type error to pass the value |
I think this can be closed. The BoxedUnit.Unit specific example isn't worth considering, as it's scala.runtime. The more general |
Fix #9166: Harden check for values in patterns based on class inheritance info
Minimized code
Output
compiles and prints "ok"
Expectation
error like in Scala 2
The text was updated successfully, but these errors were encountered: