relax "!null" contract checking to accept exceptions thrown (IDEA-133488)

This commit is contained in:
peter
2015-04-08 18:13:15 +02:00
parent 5c964ca6fc
commit 4ec8011316
4 changed files with 20 additions and 2 deletions
@@ -0,0 +1,17 @@
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
class Foo {
@Contract(value = "_, true -> !null")
public @Nullable String noNotAllowed(@NotNull String bar, boolean reallyNotAllowed) {
if (bar.equals("no")) {
if (reallyNotAllowed) {
throw new IllegalArgumentException("heck no");
}
return null;
}
return bar;
}
}