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

Fix EnclosingMethod for lifted anonfun #20558

Merged
merged 2 commits into from
Jun 17, 2024
Merged

Conversation

dwijnand
Copy link
Member

@dwijnand dwijnand commented Jun 11, 2024

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

@@ -0,0 +1 @@
public static final TB A.A$$anon$1$$_$_$$anonfun$1()
Copy link
Member

Choose a reason for hiding this comment

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

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.
@dwijnand dwijnand marked this pull request as ready for review June 13, 2024 16:34
@dwijnand dwijnand requested a review from lrytz June 13, 2024 16:34
Copy link
Member

@lrytz lrytz left a comment

Choose a reason for hiding this comment

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

👍

@lrytz lrytz merged commit 4d391dc into scala:main Jun 17, 2024
24 checks passed
@dwijnand dwijnand deleted the fix-EnclosingMethod branch June 17, 2024 17:59
@Kordyjan Kordyjan added this to the 3.5.1 milestone Jul 3, 2024
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]
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.

InternalError "Enclosing method not found"
3 participants