mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 03:13:40 +07:00
support multi-clause contracts (IDEA-93372)
This commit is contained in:
@@ -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();}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user