Fix EnclosingMethod for lifted anonfun#20558
Merged
lrytz merged 2 commits intoscala:mainfrom Jun 17, 2024
Merged
Conversation
lrytz
reviewed
Jun 12, 2024
tests/run/i18701.check
Outdated
| @@ -0,0 +1 @@ | |||
| public static final TB A.A$$anon$1$$_$_$$anonfun$1() | |||
Member
There was a problem hiding this comment.
I think this is not what's desired, the enclosing method should be tb. The EnclosingMethod attribute (aka OUTERCLASS) should represent the source level view.
There's a very long comment here: https://github.com/scala/scala3/blob/3.4.2/compiler/src/dotty/tools/backend/jvm/BTypes.scala#L341
There's a test suite for InnerClass / EnclosingMethod attributes at https://github.com/scala/scala/tree/2.13.x/test/files/jvm/innerClassAttribute which was not ported 1:1 to scala 3, but @prolativ worked on the attributes in #11589.
The anonfun "() => new TB {.." code is lifted to a static method, in the
original class (A), but the GenBCode logic was still returning the TA
anon class.
26dddca to
5c295f1
Compare
WojciechMazur
added a commit
that referenced
this pull request
Jul 10, 2024
Backports #20558 to the LTS branch. PR submitted by the release tooling. [skip ci]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The anonfun "() => new TB {.." code is lifted to a static method, in the
original class (A), but the GenBCode logic was still returning the TA
anon class.
Fixes #18701