-
Notifications
You must be signed in to change notification settings - Fork 1.1k
typed patterns get more precise types in scalac than dotty #3208
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
It works if you replace |
Had a quick look at the spec and I couldn't find anything substantiating the current scalac behavior, in particular http://www.scala-lang.org/files/archive/spec/2.13/08-pattern-matching.html#typed-patterns says:
@odersky Are you OK with replicating the behavior of scalac here? Here's a simple example illustrating the difference: trait X
trait Y
object Test {
def foo(x: X) = x match {
case y: Y =>
val b: X = y // compiles with scalac, type mismatch with dotty
}
} |
Pattern matching desperately needs a spec. It would be good if someone could start working on the issue. I think the |
Here is another example that does not compile with Dotty, I found in the community build: trait MyError { this: Throwable =>
...
}
try ...
catch {
case e: MyError =>
throw e
} The self-type is not required to compile with scalac but it was in the example |
For a pattern like `x @ P`, x get the type of the scrutinee and pattern. E.g: ``` (x: X) match case { y: Y => ... } ``` Above, `y` type to `X & Y`.
For a pattern like `x @ P`, x get the type of the scrutinee and pattern. E.g: ``` (x: X) match case { y: Y => ... } ``` Above, `y` type to `X & Y`.
The following code snippet fails to compile
The text was updated successfully, but these errors were encountered: