-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Shorter flattened names for nested $anons #852
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
The following commit will change that phase to elide the noisy `$anon1$anon2` intermediaries from flat names of nested anonymous functions and classes.
This avoids ugly class names like Foo$anon1$anon2$anon3 when defining anonymous functions or classes in a nested location.
|
Started jenkins job pr-scala-testsuite-linux-opt at https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/459/ |
|
jenkins job pr-scala-testsuite-linux-opt: Failed - https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/459/ |
|
Build failure. Works for me: PLS REBUILD ALL |
|
Started jenkins job pr-scala-testsuite-linux-opt at https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/461/ |
|
jenkins job pr-scala-testsuite-linux-opt: Success - https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/461/ |
Under the new scheme, they retain the method suffix added in SI-101.
|
Started jenkins job pr-scala-testsuite-linux-opt at https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/466/ |
|
jenkins job pr-scala-testsuite-linux-opt: Success - https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/466/ |
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.
I never really figured out whether it was intentional or not, but ANON_CLASS_NAME is a substring of ANON_FUN_NAME, so the above is redundant. You can just check for ANON_CLASS_NAME. Which has obvious unintended consequences:
package foo
object bar {
class anonymize { }
}
// scala> afterFlatten(intp.terms("foo").info.members filter (_.isAnonymousClass))
// res0: List[$r.intp.global.Symbol] = List(anonymous class bar$anonymize)
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.
Yep, it's pretty loose as it stands. I was trying not to rely on that quirk, but that at least warrants a comment.
|
@odersky Anonymous functions owned by a method are suffixed with the method name; this still happens after this patch (see the expanded test in 9629175). The current scheme seems to stop short of being useful for serialization/JRebel: flat names are prefixed with owner chain, but the unflattened name is used to generate fresh names in flatten, meaning that the names of all anonymous classes and of all non-method-owned anonymous functions are sensitive to the overall position in the compilation unit. I was also considering appending the name of the first parent class to the generated name of an anonymous class, e.g. I'm going to close this PR, implement some refinements, and then discuss further on scala-internals. This can wait until after 2.10. |
scala-internals thread
The effect of the change is best described by the diff of flatten.check
Review by @paulp, @odersky
$anonFun,$anon: is there anything else that could have the same treatment?rawownerchain was a bit fiddly to write and should be scrutinized. I didn't find an existing method onSymbolthat did what I needed.References SI-3623.