-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Restructure Try node. #202
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
Conversation
@odersky please review |
In Scala2, handlers of
Only
Perhaps this is a conscious generalisation of the existing facility, though. |
I also notice that we allow an expression that is implicit convertible to that type.
The spec says:
The implementation wrongly appears to assume I have lodged this as https://issues.scala-lang.org/browse/SI-8945. |
List(CaseDef(Ident(nme.DEFAULT_EXCEPTION_NAME), EmptyTree, Apply(handler, Ident(nme.DEFAULT_EXCEPTION_NAME)))), | ||
finalizer) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the dotty parser designed as a desugaring-free zone?
I proposed the representation in the PR, but Jason is right. It is not good that the parser does this desugaring. The parser represents naked case blocks
as
and after desugaring we would make sure that the handler is always of the form
What do people think about this? |
SGTM |
@odersky In case Try after desugaring(and typeing) should always have handlers as cases, I believe it would be better to have this enforced by types. What do you think? |
026cd91
to
5ec0bdf
Compare
Simplifies a lot handling of Try blocks in patmat and in tailrec.
Box& unbox methods are defined in companion objects.
It doesn't exist. Also use symbol with 'ex' name as selector for exceptions
After erasure was always wrong(didn't include the type of handler). Now it's able to use both Closures and desugared Math nodes.
Now Try node always has cases as handlers. In case handler is an Ident of type Throwable => T than it's desugared to a CaseDef during parsing.
It's not used anymore as superseded by previous commit.
Instead of desugaring in parser desugaring is now done during desugaring.
a1333a7
to
9d1b4bf
Compare
@@ -60,7 +61,10 @@ class Run(comp: Compiler)(implicit ctx: Context) { | |||
|
|||
private def printTree(ctx: Context) = { | |||
val unit = ctx.compilationUnit | |||
println(s"result of $unit after ${ctx.phase.prev}:") | |||
val prevPhase = ctx.phase.prev // can be a mini-phase | |||
val squahsedPhase = ctx.squashed(prevPhase) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo
Otherwise LGTM. |
Now Try node always has cases as handlers. In case handler is an Ident of
type Throwable => T than it's desugared to a CaseDef during parsing.