Skip to content

Commit

Permalink
ecj fails to understand assignment of lambda to local in ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
stephan-herrmann committed Feb 1, 2025
1 parent ac090fc commit e8d61fd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ private void internalAnalyseCode(FlowContext flowContext, FlowInfo flowInfo) {
((ConstructorDeclaration) method).analyseCode(this.scope, initializerContext, ctorInfo,
ctorInfo.reachMode(), ConstructorDeclaration.AnalysisMode.PROLOGUE);
if (prologueInfo == null)
prologueInfo = ctorInfo;
prologueInfo = ctorInfo.copy();
else
prologueInfo = prologueInfo.mergeDefiniteInitsWith(ctorInfo.unconditionalInits()); // will only evaluate field inits below
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2904,4 +2904,29 @@ class TestUseTree2_ROOT1 {
----------
""");
}
public void testGH3654() throws Exception {
// from https://bugs.openjdk.org/browse/JDK-8334252
runConformTest(new String[] {
"LambdaOuterCapture.java",
"""
public class LambdaOuterCapture {
public class Inner {
public Inner() {
Runnable r = () -> System.out.println(LambdaOuterCapture.this);
this(r);
}
public Inner(Runnable r) {
}
}
public static void main(String[] args) {
new LambdaOuterCapture().new Inner();
}
}
"""},
"");
}
}

0 comments on commit e8d61fd

Please sign in to comment.