[java-inference] Failure contract inference improved

GitOrigin-RevId: 687b4c909c1d2ae67d519ec71899d52fa3e29434
This commit is contained in:
Tagir Valeev
2021-03-11 11:27:56 +00:00
committed by intellij-monorepo-bot
parent 23e19832d4
commit b4c69a9cec
31 changed files with 387 additions and 111 deletions
@@ -13,6 +13,25 @@ import java.nio.file.Files;
*/
@SuppressWarnings({"unused", "IOResourceOpenedButNotSafelyClosed"})
public class Test01 {
@ExpectContract("true,_->fail")
static void checkNegate(boolean val, String s1) {
check(!val, s1, null);
}
@ExpectContract("false,_->fail")
static void check1(boolean val, String s1) {
check(val, s1, null);
}
@ExpectContract("false,_,_->fail")
static void check(boolean val, String s1, String s2) {
if (!val) {
throw new RuntimeException(createMessage(s1, s2));
}
}
native static String createMessage(String s1, String s2);
@ExpectNotNull
@ExpectContract(pure = true)
public static MySupplier methodReference(@ExpectNotNull String s) {