Skip to content
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

Do not bring forward symbols created in transform and backend phases #21865

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

jchyb
Copy link
Contributor

@jchyb jchyb commented Oct 31, 2024

Fixes #21844
In the issue minimization, first the Macro.scala and SuperClassWIthLazyVal.scala compilation units are compiled, then in the next run SubClass.scala is compiled. While compiling SuperClassWIthLazyVal.scala, in the LazyVals transform phase, the lzyINIT initialization fields are created. In the next run, while compiling SubClass.scala, in the GenBCode 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 in MoveStatics, 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.

@jchyb jchyb changed the title experiment: do not bring forward symbols defined in transform and backend phases experiment: do not bring forward symbols created in transform and backend phases Oct 31, 2024
@jchyb jchyb force-pushed the fix-i21844-stale-sym branch from 0e50d0c to 782ee38 Compare December 2, 2024 13:58
@jchyb jchyb force-pushed the fix-i21844-stale-sym branch from 782ee38 to 2a2245f Compare December 2, 2024 14:03
@jchyb jchyb changed the title experiment: do not bring forward symbols created in transform and backend phases Do not bring forward symbols created in transform and backend phases Dec 3, 2024
@jchyb jchyb marked this pull request as ready for review December 3, 2024 09:59
@jchyb jchyb requested a review from dwijnand December 3, 2024 09:59
@dwijnand
Copy link
Member

dwijnand commented Dec 3, 2024

@odersky have you seen this? I haven't looked yet, but wanted to get your input as well.

Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think this might work. Keeping fingers crossed :-)

@odersky odersky removed their assignment Dec 5, 2024
@jchyb jchyb merged commit 7d9771d into scala:main Dec 5, 2024
29 checks passed
@jchyb jchyb deleted the fix-i21844-stale-sym branch December 5, 2024 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stale symbol when calling a macro in companion object when superclass has a lazy val
3 participants