-
Notifications
You must be signed in to change notification settings - Fork 21
Typer inlines constants and makes dependency analysis impossible #7173
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
Imported From: https://issues.scala-lang.org/browse/SI-7173?orig=1 |
@JamesIry said: |
@gkossakowski said: The improved incremental compiler I'm working on relies on extracting used names in a given compilation unit. Once constant gets inlined we do not have access to the field that defined it therefore we can't extract its name. I thought I could work-around it by inspecting symbol names of symbols in Therefore I believe there's no other way than just fix the underlaying issue. According to Adriaan we could perform constant inlining and folding based purely on types and leave trees intact. We still want constants to be folded in the bytecode so we could replace trees having constant types with actual constants in some later phase like erasure. This is an interesting idea that I would like to try out at some point. |
@jvican said (edited on Feb 4, 2017 9:45:41 AM UTC): The following test in Zinc is failing because of it. Could someone confirm this hasn't been fixed in new Scala versions and set those versions in the ticket? This constant inlining could be perjudicial for a lot of Zinc users that make intense use of final vals. I think it would make sense to fix this and I'd be happy to take a stab at it. I'd like to know if @adriaanm or @retronym would accept such a PR for next 2.12.x and 2.11.x series (if there's to a be a new version for 2.11). A time estimate to fix this would also be very useful to pick the appropriate moment to implement it. I think this could be a blocker for a fully stable Zinc 1.0 release (though we could probably live with it since it depends on the compiler). |
@milessabin said: |
@dwijnand said: |
@milessabin said: |
Adds an original tree attachment that allows external tools (compiler plugins like scalameta & zinc) to keep track of the previous, unadapted tree. The reason why this is required is explained in SD-340: scala/scala-dev#340. This change enables the incremental compiler to detect changes in `final val`s: sbt/zinc#227. It also enables a fix for scala/bug#10426 by allowing the scaladoc compiler to let the compiler adapt literals without losing the tree that will be shown in the Scaladoc UI. To maintainers: I was thinking of the best way to test this, but couldn't come up with an elegant one. Do you suggest a way I could write a test for this? Is there a precedent in testing information carried in the trees? I think @lrytz is the right person to review this, since he suggested this fix in the first place.
Adds an original tree attachment that allows external tools (compiler plugins like scalameta & zinc) to keep track of the previous, unadapted tree. The reason why this is required is explained in SD-340: scala/scala-dev#340. This change enables the incremental compiler to detect changes in `final val`s: sbt/zinc#227. It also enables a fix for scala/bug#10426 by allowing the scaladoc compiler to let the compiler adapt literals without losing the tree that will be shown in the Scaladoc UI. To maintainers: I was thinking of the best way to test this, but couldn't come up with an elegant one. Do you suggest a way I could write a test for this? Is there a precedent in testing information carried in the trees? I think @lrytz is the right person to review this, since he suggested this fix in the first place.
Adds an original tree attachment that allows external tools (compiler plugins like scalameta & zinc) to keep track of the previous, unadapted tree. The reason why this is required is explained in SD-340: scala/scala-dev#340. This change enables the incremental compiler to detect changes in `final val`s: sbt/zinc#227. It also enables a fix for scala/bug#10426 by allowing the scaladoc compiler to let the compiler adapt literals without losing the tree that will be shown in the Scaladoc UI. To maintainers: I was thinking of the best way to test this, but couldn't come up with an elegant one. Do you suggest a way I could write a test for this? Is there a precedent in testing information carried in the trees? I think @lrytz is the right person to review this, since he suggested this fix in the first place. Fixes scala/bug#7173.
Adds an original tree attachment that allows external tools (compiler plugins like scalameta & zinc) to keep track of the previous, unadapted tree. The reason why this is required is explained in SD-340: scala/scala-dev#340. This change enables the incremental compiler to detect changes in `final val`s: sbt/zinc#227. It also enables a fix for scala/bug#10426 by allowing the scaladoc compiler to let the compiler adapt literals without losing the tree that will be shown in the Scaladoc UI. To maintainers: I was thinking of the best way to test this, but couldn't come up with an elegant one. Do you suggest a way I could write a test for this? Is there a precedent in testing information carried in the trees? I think @lrytz is the right person to review this, since he suggested this fix in the first place. Fixes scala/bug#7173.
Here's another symptom of the fact that we constant fold term trees:
|
See also #10340 (comment) |
The problem has been mentioned here:
https://groups.google.com/d/topic/scala-internals/b95Y-GbXVGA/discussion
The gist is that typer inlines compile time constants (e.g. references to static fields defined in Java) and forgets about the original tree that referred to a constant (e.g. to a field) which makes dependency analysis impossible.
According to Adriaan pattern matcher does not need constants to be inlined because it works with types. I couldn't readily find a reason why we need to inline those constants in typer so we probably should move this all the way to erasure.
I'm logging a ticket to not forget to investigate if we can do that for 2.10.2.
The text was updated successfully, but these errors were encountered: