-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[DO NOT MERGE] Illustrate issue with TreeTypeMap and miniphases #1770
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
When running TreeTypeMap in a miniphase, the tree we're transforming has already been transformed by all the miniphases in the same group, but the symbols we're looking at might be older than the trees, this means that we can miss transforming some symbols as illustrated in details by the added testcase which currently fails.
With this commit, tests/pos/treetypemap-miniphase.scala now compiles, but this is only a hack: there are other instances of TreeTypeMap in the compiler and they would all need to be run with "atGroupEnd", this is tricky since we are not always calling TreeTypeMap in a context where we have access to the current TreeTransformer (for example when we create a TreeTypeMap inside TypeMap to deal with annotations), ideas and alternative fixes welcome.
In short: we have already encountered this issue and we have introduced If I remember correctly @odersky proposed to keep |
Similarly: |
@@ -80,7 +80,9 @@ class ElimByName extends MiniPhaseTransform with InfoTransformer { thisTransform | |||
val inSuper = if (ctx.mode.is(Mode.InSuperCall)) InSuperCall else EmptyFlags | |||
val meth = ctx.newSymbol( | |||
ctx.owner, nme.ANON_FUN, Synthetic | Method | inSuper, MethodType(Nil, Nil, argType)) | |||
Closure(meth, _ => arg.changeOwner(ctx.owner, meth)) | |||
atGroupEnd { implicit ctx: Context => | |||
Closure(meth, _ => arg.changeOwner(ctx.owner, meth)) |
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.
try changeOwnerAfter
. It's supposed to fix the issue. No need for atGroupEnd
.
The correct solution to this issue is to only change denotations\owners in InfoTransormer. Than neither of those functionalities would have been needed. |
No, it's the opposite. But there are other tree type maps, for instance in tailrec and extensionMethods. So we need to be careful with those. |
That's what I thought too, but that seems like a major refactoring since many phases change denotations while transforming trees. |
In particular, every |
Using changeOwnerAfter would be more appropriate but currently fails with an assertion in LambdaLift
Using changeOwnerAfter would be more appropriate but currently fails with an assertion in LambdaLift
Using changeOwnerAfter would be more appropriate but currently fails with an assertion in LambdaLift
Using changeOwnerAfter would be more appropriate but currently fails with an assertion in LambdaLift
Using changeOwnerAfter would be more appropriate but currently fails with an assertion in LambdaLift
Using changeOwnerAfter would be more appropriate but currently fails with an assertion in LambdaLift
Using changeOwnerAfter would be more appropriate but currently fails with an assertion in LambdaLift
Closed in favor of opening an issue |
Ping @DarkDimius @odersky, I'm not sure how to proceed from here.
The first commit illustrates the issue:
The second commit contains a hack to show that my diagnostic of the issue above is correct, but I don't know how to fix this properly: