dfa: support contracts with no args (IDEA-127768)

This commit is contained in:
peter
2014-07-29 19:33:15 +02:00
parent 42e2dc2edf
commit 214cf92b0f
8 changed files with 43 additions and 16 deletions
@@ -19,6 +19,6 @@
}
public static void bar() throws CheckedException {
throw new CheckedException();
if (new Random().nextInt() > 2) throw new CheckedException();
}
}
@@ -7,7 +7,7 @@
</problem>
<problem>
<file>IDEADEV10489.java</file>
<line>12</line>
<line>8</line>
<description>Method invocation 's.length()' may produce NullPointerException</description>
</problem>
</problems>
@@ -1,7 +1,5 @@
class IDEADEV10489 {
static String getS() {
return null;
}
static native String getS();
static void f() {
String s = getS();
@@ -17,7 +15,5 @@ class IDEADEV10489 {
}
}
private static boolean foo() {
return false;
}
private static native boolean foo();
}
@@ -18,7 +18,5 @@ class Test {
}
}
private static @NotNull String createString() {
throw new NullPointerException();
}
private static native @NotNull String createString();
}
@@ -1,3 +1,5 @@
import java.util.Random;
class BrokenAlignment {
public static void main(String[] args) {
@@ -20,7 +22,7 @@ class BrokenAlignment {
}
public static void doSomething() {
throw new RuntimeException("dummy");
if (new Random().nextInt() > 2) throw new RuntimeException("dummy");
}
}
@@ -0,0 +1,24 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
class Doo {
@NotNull
public String doSomething() {
String s = getSomeString();
if (s == null) {
throwSomeError();
}
return s;
}
private static void throwSomeError() {
throw new RuntimeException();
}
@Nullable
public String getSomeString() {
return Math.random() > 0.5 ? null : "Yeah";
}
}
@@ -252,6 +252,7 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
public void testRootThrowableCause() { doTest(); }
public void testUseInferredContracts() { doTest(); }
public void testContractWithNoArgs() { doTest(); }
public void testContractInferenceBewareOverriding() { doTest(); }
public void testNumberComparisonsWhenValueIsKnown() { doTest(); }