Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
}
manageEnclosingInstanceAccessIfNecessary(currentScope, flowInfo);
updateMaxFieldCount(); // propagate down the max field count
internalAnalyseCode(flowContext, flowInfo);
internalAnalyseCode(flowContext, flowInfo.unconditionalFieldLessCopy()); // discards info about fields of enclosing classes
} catch (AbortType e) {
this.ignoreFurtherInvestigation = true;
}
Expand Down Expand Up @@ -300,7 +300,7 @@ public void analyseCode(ClassScope currentScope, FlowContext flowContext, FlowIn
}
manageEnclosingInstanceAccessIfNecessary(currentScope, flowInfo);
updateMaxFieldCount(); // propagate down the max field count
internalAnalyseCode(flowContext, flowInfo);
internalAnalyseCode(flowContext, flowInfo.unconditionalFieldLessCopy()); // discards info about fields of enclosing classes
} catch (AbortType e) {
this.ignoreFurtherInvestigation = true;
}
Expand Down Expand Up @@ -744,8 +744,8 @@ private void internalAnalyseCode(FlowContext flowContext, FlowInfo flowInfo) {
InitializationFlowContext initializerContext = new InitializationFlowContext(parentContext, this, flowInfo, flowContext, this.initializerScope);
// no static initializer in local classes, thus no need to set parent:
InitializationFlowContext staticInitializerContext = new InitializationFlowContext(null, this, flowInfo, flowContext, this.staticInitializerScope);
FlowInfo nonStaticFieldInfo = flowInfo.unconditionalFieldLessCopy(); // discards info about fields of inclosing classes
FlowInfo staticFieldInfo = flowInfo.unconditionalFieldLessCopy();
FlowInfo nonStaticFieldInfo = flowInfo.copy();
FlowInfo staticFieldInfo = flowInfo.copy();

if (JavaFeature.FLEXIBLE_CONSTRUCTOR_BODIES.isSupported(this.scope.compilerOptions())) {
if (this.methods != null) {
Expand Down Expand Up @@ -856,7 +856,7 @@ private void internalAnalyseCode(FlowContext flowContext, FlowInfo flowInfo) {
}
}
if (this.methods != null) {
UnconditionalFlowInfo outerInfo = flowInfo.unconditionalFieldLessCopy();
FlowInfo outerInfo = flowInfo.copy();
if (nonStaticFieldInfo instanceof UnconditionalDualFlowInfo udfi) {
nonStaticFieldInfo = udfi.getMainInits(); // drop info from prologues
} else if (nonStaticFieldInfo instanceof DualFlowInfo dfi) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3617,5 +3617,61 @@ public Test() {
----------
""");
}
// https://github.com/eclipse-jdt/eclipse.jdt.core/issues/4700
public void testIssue4700() {
runConformTest(new String[] {
"Test.java",
"""
public class Test {
private final Object a;
public Test() {
a = new Object();
class Test2 {
private final Object b;
public Test2() {
System.out.println();
super();
b = new Object();
}
}
}
}
"""
});
}
public void testIssue4700b() {
runNegativeTest(new String[] {
"Test.java",
"""
@SuppressWarnings("unused")
public class Test {
private final Object a;
public Test() {
a = new Object();
class Test2 {
private final Object b;
public Test2() {
System.out.println();
super();
try {
b = new Object();
} finally {
a = new Object();
}
}
}
}
}
"""
},
"""
----------
1. ERROR in Test.java (at line 14)
a = new Object();
^
The final field Test.a cannot be assigned
----------
""");
}
}

Loading