allow dfa inspection to treat all non-annotated members as nullable (IDEA-129898)

This commit is contained in:
peter
2014-09-16 13:50:45 +02:00
parent e2ee62224c
commit 984af0337e
9 changed files with 73 additions and 8 deletions
@@ -0,0 +1,22 @@
import org.jetbrains.annotations.NotNull;
class Test {
Object o;
void field() {
<warning descr="Method invocation 'o.hashCode()' may produce 'java.lang.NullPointerException'">o.hashCode()</warning>;
}
void callUnknownMethod() {
<warning descr="Method invocation 'unknownObject().hashCode()' may produce 'java.lang.NullPointerException'">unknownObject().hashCode()</warning>;
}
void callNotNullMethod() {
knownObject().hashCode();
}
native Object unknownObject();
@NotNull
native Object knownObject();
}
@@ -137,6 +137,13 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
myFixture.testHighlighting(true, false, true, getTestName(false) + ".java");
}
public void testParanoidMode() {
final DataFlowInspection inspection = new DataFlowInspection();
inspection.TREAT_UNKNOWN_MEMBERS_AS_NULLABLE = true;
myFixture.enableInspections(inspection);
myFixture.testHighlighting(true, false, true, getTestName(false) + ".java");
}
public void testReportConstantReferences() {
doTestReportConstantReferences();
myFixture.launchAction(myFixture.findSingleIntention("Replace with 'null'"));