[r=peter] dfa regression. Even finals must be flashed when they leave their declaration scope

This commit is contained in:
Maxim Shafirov
2011-12-02 13:50:40 +04:00
parent db9e26a218
commit 977679a62d
6 changed files with 31 additions and 1 deletions
@@ -58,4 +58,6 @@ public interface DfaMemoryState {
boolean canBeNaN(DfaValue dfaValue);
boolean isNotNull(DfaVariableValue dfaVar);
void flushVariableOutOfScope(DfaVariableValue variable);
}
@@ -691,6 +691,12 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
doFlash((DfaVariableValue)variable.createNegated());
}
@Override
public void flushVariableOutOfScope(DfaVariableValue variable) {
doFlash(variable);
doFlash((DfaVariableValue)variable.createNegated());
}
private void doFlash(DfaVariableValue variable) {
final int id = variable.getID();
int size = myEqClasses.size();
@@ -119,7 +119,7 @@ public abstract class InstructionVisitor {
public DfaInstructionState[] visitFlushVariable(FlushVariableInstruction instruction, DataFlowRunner runner, DfaMemoryState memState) {
final DfaVariableValue variable = instruction.getVariable();
if (variable != null) {
memState.flushVariable(variable);
memState.flushVariableOutOfScope(variable);
} else {
memState.flushFields(runner);
}
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems/>
@@ -0,0 +1,17 @@
public class AAA {
public static void main(String[] args) {
for (int i = 0; i < args.length; i++) {
final String element = args[i];
if (i == 1) {
if (element != null) { // !!!!! WRONG: element[1] == null
return;
}
}
else if (element == null) {
return;
}
}
}
}
@@ -82,6 +82,8 @@ public class DataFlowInspectionTest extends InspectionTestCase {
public void testIDEADEV74518_2() throws Exception { doTest(); }
public void testIDEADEV77819() throws Exception { doTest(); }
public void testRegressionByPti() throws Exception { doTest(); }
public void testNotNullable() throws Exception { doTest15(); }
public void testNotNullableParameter() throws Exception { doTest15(); }