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 names of anonymous classes defined in lambdas #5207

Merged
merged 1 commit into from
Jan 6, 2025

Conversation

johannescoetzee
Copy link
Contributor

@johannescoetzee johannescoetzee commented Jan 6, 2025

When an anonymous class is defined, the name of the enclosing scope is prepended to the anonymous class name to ensure uniqueness. I previously used an empty method node for lambda methods, however, so the enclosing scope name for anonymous classes in lambdas would just be <empty>. This resulted in duplicate anonymous class names being possible and in an edge case where orphan locals were created in anonymous classes of the same name where one is defined in a lambda in a static scope and one in a non-static scope.

This PR fixes this issue by using the actual lambda method node in the scope.

@johannescoetzee johannescoetzee requested review from maltek and ml86 January 6, 2025 14:45
Comment on lines -122 to +127
case (Some(returnTpe), Some(parameterTpes)) if !containsEmptyType =>
composeMethodLikeSignature(returnTpe, parameterTpes)
case (Some(returnType), Some(parameterTypes)) if !containsEmptyType =>
composeMethodLikeSignature(returnType, parameterTypes)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just a typo I saw while working on this. I could move this to a separate PR, but I thought I'd include it here since the PR is relatively small anyways

@johannescoetzee johannescoetzee merged commit 578b422 into master Jan 6, 2025
5 checks passed
@johannescoetzee johannescoetzee deleted the johannes/anonymous-name-fix branch January 6, 2025 15:19
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.

2 participants