dfa: if a variable is not nullable-enabled, don't make it such

This commit is contained in:
peter
2013-09-26 21:34:46 +02:00
parent 304a3b6004
commit dea8248bfe
3 changed files with 20 additions and 1 deletions
@@ -79,7 +79,7 @@ class StateMerger {
for (DfaVariableValue unknownVar : removedState.getUnknownVariables()) {
copy.doFlush(unknownVar, true);
}
if (removedState.isNull(var)) {
if (removedState.getVariableState(var).isNullable()) {
copy.setVariableState(var, copy.getVariableState(var).withNullability(Nullness.NULLABLE));
}
}
@@ -0,0 +1,18 @@
import java.io.File;
class Some {
private void findRepository(File file, boolean b) {
System.out.println(file.getName());
if (b) {
File parent = file;
while (parent != null) {
parent = parent.getParentFile();
}
System.out.println(<warning descr="Method invocation 'parent.getName()' may produce 'java.lang.NullPointerException'">parent.getName()</warning>);
}
System.out.println(file.getName());
}
}
@@ -302,6 +302,7 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
public void testManySequentialIfsNotComplex() { doTest(); }
public void testLongDisjunctionsNotComplex() { doTest(); }
public void testWhileNotComplex() { doTest(); }
public void testVariablesDiverge() { doTest(); }
public void _testNullCheckBeforeInstanceof() { doTest(); }
}