IDEA-89964 Constant conditions & exceptions inspection is incorrect with instance checks in loops

This commit is contained in:
peter
2012-09-10 14:15:41 +02:00
parent b8d339d1e3
commit d13b70d875
3 changed files with 19 additions and 1 deletions
@@ -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(); }
}