mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-89964 Constant conditions & exceptions inspection is incorrect with instance checks in loops
This commit is contained in:
@@ -736,7 +736,8 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
}
|
||||
|
||||
public void flushVariable(@NotNull DfaVariableValue variable) {
|
||||
if (variable.getPsiVariable().hasModifierProperty(PsiModifier.FINAL)) {
|
||||
PsiVariable psiVariable = variable.getPsiVariable();
|
||||
if (psiVariable instanceof PsiField && psiVariable.hasModifierProperty(PsiModifier.FINAL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
public class Test {
|
||||
|
||||
public static void main(Object[] args) throws Exception {
|
||||
boolean elvisLives = false;
|
||||
for (final Object o : args) {
|
||||
if (o instanceof Integer) {
|
||||
elvisLives = true;
|
||||
} else {
|
||||
if (elvisLives) {
|
||||
System.err.println("Elvis is alive!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -75,5 +75,6 @@ public class DataFlowInspectionFixtureTest extends JavaCodeInsightFixtureTestCas
|
||||
public void testNotEqualsDoesntImplyNotNullity() throws Throwable { doTest(); }
|
||||
public void testEqualsEnumConstant() throws Throwable { doTest(); }
|
||||
public void testEqualsConstant() throws Throwable { doTest(); }
|
||||
public void testFinalLoopVariableInstanceof() throws Throwable { doTest(); }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user