Do not bring forward symbols created in transform and backend phases #21865
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #21844
In the issue minimization, first the
Macro.scala
andSuperClassWIthLazyVal.scala
compilation units are compiled, then in the next runSubClass.scala
is compiled. While compilingSuperClassWIthLazyVal.scala
, in theLazyVals
transform phase, the lzyINIT initialization fields are created. In the next run, while compilingSubClass.scala
, in theGenBCode
phase, the compiler would try to access the lzyINIT symbol, leading to a stale symbols crash. While that symbol was a part of the SuperClass, it by design is not generated for the Subclass - if we were to completely split those files into 2 separate compilations, that symbol would be created only for the classfile, but it would not be included in tasty, so the second compilation would not try to access it.This observation inspires the proposed fix, where if the symbol was first created in or after the first transform phase (so after the pickler phases), we do not try to bring forward this denotation, instead returning NoDenotation.
In this PR, we also remove the fix proposed in #21559, as it is no longer necessary with the newly added condition. There, since one of the problematic Symbols created in
LazyVals
was moved elsewhere inMoveStatics
, we checked if that symbol could be found in a companion object. I was not able to create any reproduction where a user defined static would produce this problem, so I believe it’s safe to remove that.