support multi-clause contracts (IDEA-93372)

This commit is contained in:
peter
2013-07-23 13:16:23 +02:00
parent 2dbc14d796
commit d0e4d4fd1b
4 changed files with 101 additions and 47 deletions
@@ -1,10 +1,16 @@
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Nullable;
import java.lang.*;
import java.lang.AssertionError;
import java.lang.IllegalArgumentException;
public class AssertIsNotNull {
void bar() {
void bar(String s) {
if (<warning descr="Condition 's == null && trimIfNotNull(s) != null' is always 'false'">s == null && <warning descr="Condition 'trimIfNotNull(s) != null' is always 'false' when reached">trimIfNotNull(s) != null</warning></warning>) {
throw new AssertionError();
}
final Object o = call();
assertIsNotNull(o);
if(<warning descr="Condition 'o == null' is always 'false'">o == null</warning>) {}
@@ -16,6 +22,14 @@ public class AssertIsNotNull {
throw new IllegalArgumentException();
}
}
@Contract("null -> null; !null -> !null")
@Nullable static String trimIfNotNull(@Nullable String s) {
if (s == null) {
return null;
}
return s.trim();
}
Object call() {return new Object();}
}