[java-dfa] handleClosure: fix escaping of 'this'

Regression introduced in IDEA-361818

GitOrigin-RevId: faed510b342995f19cbee5d56138132c7c209662
This commit is contained in:
Tagir Valeev
2024-11-15 14:31:31 +00:00
committed by intellij-monorepo-bot
parent 467aef7509
commit 1b10ecf7f1
3 changed files with 26 additions and 0 deletions
@@ -806,6 +806,9 @@ public class ControlFlowAnalyzer extends JavaElementVisitor {
if (descriptor != null) {
descriptors.add(descriptor);
}
if (JavaDfaValueFactory.getQualifierOrThisValue(myFactory, expression) instanceof DfaVariableValue dfaVar) {
descriptors.add(dfaVar.getDescriptor());
}
}
@Override
@@ -0,0 +1,22 @@
import java.util.function.BooleanSupplier;
class FieldWriteInLambda {
private String myField;
FieldWriteInLambda(boolean b) {
BooleanSupplier r = () -> {
myField = Math.random() > 0.5 ? "foo" : <warning descr="Assigning 'null' value to non-annotated field">null</warning>;
return myField != null;
};
if (b) {
r.getAsBoolean();
if (myField == null) {
}
} else if (r.getAsBoolean()) {
if (myField == null) {
}
}
}
}
@@ -379,4 +379,5 @@ public class DataFlowInspection8Test extends DataFlowInspectionTestCase {
setupTypeUseAnnotations("typeUse", myFixture);
doTest();
}
public void testFieldWriteInLambda() { doTest(); }
}