mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
dfa: if a variable is not nullable-enabled, don't make it such
This commit is contained in:
@@ -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(); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user