IDEA-87652

This commit is contained in:
anna
2012-07-05 16:13:20 +02:00
parent cf90acfe21
commit 7678df1cbb
4 changed files with 28 additions and 1 deletions
@@ -540,7 +540,7 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
DfaTypeValue dfaType = (DfaTypeValue)dfaCond.getRightOperand();
final DfaVariableState varState = getVariableState(dfaVar);
varState.setNullable(dfaType.isNullable());
varState.setNullable(varState.isNullable() || dfaType.isNullable());
return !isNotNull(dfaVar) || varState.setInstanceofValue(dfaType);
}
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>Npe.java</file>
<line>6</line>
<description>Method invocation &lt;code&gt;((SomeInterfaceImpl)x).bar()&lt;/code&gt; may produce &lt;code&gt;java.lang.NullPointerException&lt;/code&gt;</description>
</problem>
</problems>
@@ -0,0 +1,18 @@
import org.jetbrains.annotations.Nullable;
public class Npe {
void foo(@Nullable SomeInterface x) {
((SomeInterfaceImpl)x).bar();
}
interface SomeInterface {
void bar();
}
class SomeInterfaceImpl implements SomeInterface {
@Override
public void bar() {
}
}
}
@@ -96,6 +96,7 @@ public class DataFlowInspectionTest extends InspectionTestCase {
public void testNullable() throws Exception { doTest15(); }
public void testNullableThroughCast() throws Exception { doTest15(); }
public void testNullableProblemThroughCast() throws Exception { doTest15(); }
public void testNullableThroughVariable() throws Exception { doTest15(); }
public void testNullableThroughVariableShouldNotBeReported() throws Exception { doTest15(); }
public void testNullableAssignment() throws Exception { doTest15(); }