-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Refactorings and fixes to erased definition handling #23404
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 motivation for the phase was always unclear to me. No tests broke after the change. Piggybacked on the phase was the unrelated "anonymous class in inline method" warning. I moved it in changed form to FirstTransform. It is more efficient now since it does not need an auxiliary tree traversal.
We assumed all type applications were pure, which is claerly false. E.g. def fn[T] = println("hi") fn[Int] This triggered a problem in coverage tests which now assumes a use of an erased function is not erased (probably because it now shows up in the coverage info). The problem was fixed by mapping the erased defs to inline defs. I found out the problem with coverage: If an argument is not a pure expression, it gets lifted into a prefix val. And the prefix val is not erased even if the parameter is erased. So that way things escape an erased context. I believe this is a fundamental problem that would also affect lifting due to other reasons (e.g. eta expansion or handling default arguments). We either have to fix the lifting to mainain erased status, or restrict erased arguments to pure expressions that don't need lifting.
If one of the methods is an inline method that is not retained, no need to report a double definition.
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.
LGTM aside from the comments. Also, this removes erased def
s right? Do we reject them while parsing now? I didn't notice any such changes.
0 | ||
macro-late-suspend/UsesTest.scala | ||
example | ||
UsesTest$package | ||
Object | ||
example.UsesTest$package | ||
<init> | ||
22 | ||
22 | ||
3 | ||
<none> | ||
Literal | ||
true | ||
0 | ||
false | ||
|
||
|
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'm not sure what this test does. Is it important that the output changes?
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 am not sure. It might have to do with the fact that we don't delete code in PruneErasedDefs anymore. But if anything this hshould be more precise now.
@@ -56,6 +56,6 @@ object ccConfig: | |||
|
|||
/** Not used currently. Handy for trying out new features */ | |||
def newScheme(using ctx: Context): Boolean = | |||
ctx.settings.XdropComments.value | |||
Feature.sourceVersion.stable.isAtLeast(SourceVersion.`3.7`) |
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.
This seems to be a random change
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.
yes, it's not needed elsewhere though.
erased defs are not yet removed. That comes later. |
These are cleanups and bug-fixes. They don't change the semantics of erasedDefinitions