mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-dfa] Remove equivalences when flushing qualified methods
Fixes IDEA-292808 False positive for "Constant conditions and exceptions": always false IF condition in inner class with use of public method GitOrigin-RevId: b8235e443ecdb9c4a37b4c16b8814e48b607a2d3
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d24dbdcf93
commit
e9950c0327
@@ -0,0 +1,24 @@
|
||||
// IDEA-292808
|
||||
class Test {
|
||||
private class Inner {
|
||||
private boolean firstCheckOk;
|
||||
private boolean secondCheckOk;
|
||||
public void firstCheck(boolean ok) {
|
||||
boolean oldOk = isOk();
|
||||
this.firstCheckOk = ok;
|
||||
boolean newOk = isOk();
|
||||
if (oldOk != newOk)
|
||||
System.out.println(newOk);
|
||||
}
|
||||
public void secondCheck(boolean ok) {
|
||||
boolean oldOk = isOk();
|
||||
this.secondCheckOk = ok;
|
||||
boolean newOk = isOk();
|
||||
if (oldOk != newOk)
|
||||
System.out.println(newOk);
|
||||
}
|
||||
public boolean isOk() {
|
||||
return firstCheckOk || secondCheckOk;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -719,4 +719,5 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase {
|
||||
public void testBoxingInConstructorArguments() { doTest(); }
|
||||
public void testBoxingInArrayDeclaration() { doTest(); }
|
||||
public void testNestedVersusSuper() { doTest(); }
|
||||
public void testChangeFieldUsedInPureMethod() { doTest(); }
|
||||
}
|
||||
|
||||
+2
-2
@@ -1381,8 +1381,8 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
private void flushQualifiedMethods(@NotNull DfaVariableValue variable) {
|
||||
if (variable.isFlushableByCalls()) {
|
||||
// Flush method results on field write
|
||||
List<DfaVariableValue> toFlush =
|
||||
ContainerUtil.filter(myVariableTypes.keySet(), DfaVariableValue::containsCalls);
|
||||
List<DfaVariableValue> toFlush = StreamEx.of(myEqClasses).flatMap(cls -> cls == null ? null : StreamEx.of(cls.iterator()))
|
||||
.append(myVariableTypes.keySet()).filter(DfaVariableValue::containsCalls).toList();
|
||||
toFlush.forEach(val -> doFlush(val, true));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user