Skip to content

Allow lambdas in this()/super() to close over outer types#10078

Merged
niloc132 merged 7 commits intogwtproject:mainfrom
niloc132:10065-lambda-test
Feb 5, 2025
Merged

Allow lambdas in this()/super() to close over outer types#10078
niloc132 merged 7 commits intogwtproject:mainfrom
niloc132:10065-lambda-test

Conversation

@niloc132
Copy link
Member

@niloc132 niloc132 commented Jan 8, 2025

Prior to JDT 3.32, passing a lambda that closes over outer types to this()/super() constructors would result in a compiler error. As of around 3.32 this is now allowed, but the closed-over instance is passed as an item in a "synthetic outer local variable" collection. Each instance in that collection has a field representing the "actual outer local variable", and in this case, that field is null.

Added tests to confirm that the generated code seems consistent, and that running such a lambda affects the expected instance.

Fixes #10065

@niloc132 niloc132 added this to the 2.13 milestone Jan 8, 2025
@niloc132
Copy link
Member Author

niloc132 commented Jan 8, 2025

@niloc132 niloc132 merged commit f1c4578 into gwtproject:main Feb 5, 2025
4 checks passed
@zbynek zbynek added the bug label Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

java.lang.NullPointerException: Cannot read field "declaringScope" because "outerLocalVariable" is null after upgrading from 2.11 to 2.12.1

3 participants