blob: 412cf0d92674276616d3ddfa0f15e5888aa88716 [file] [log] [blame]
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
class Foo {
public void main(@NotNull Object nn) {
foo(nn).hashCode();
}
@Contract("null->null;!null->!null")
@Nullable
Object foo(Object a) { return a; }
@NotNull
Object notNull() {
return <warning descr="Expression 'nullable(false)' might evaluate to null but is returned by the method declared as @NotNull">nullable(false)</warning>;
}
@NotNull
Object notNull2() {
return <warning descr="Expression 'nullable2(false)' might evaluate to null but is returned by the method declared as @NotNull">nullable2(false)</warning>;
}
@Nullable
@Contract("true -> !null")
Object nullable(boolean notNull) {
return notNull ? "" : anotherNullable();
}
@Nullable
@Contract("true -> !null; _->_")
Object nullable2(boolean notNull) {
return notNull ? "" : anotherNullable();
}
@Nullable
Object anotherNullable() {
return null;
}
}