import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
interface NonnullInterface {
@NotNull
Object nonNullMethod();
}
class P2 {
private void callTest() {
test(new NonnullInterface() {
@Nullable
@Override
public String nonNullMethod() {
return null;
}
});
test(this::getNull);
test(this::getPrimitive);
test(this::getNonAnnotated);
test(WithImplicitConstructor::new);
test(WithExplicitConstructor::new);
}
@Nullable
String getNull() { return null; }
String getNonAnnotated() { return null; }
boolean getPrimitive() { return true; }
private void test(final NonnullInterface function) { }
private Iterable arrayToIterable(String... array) {
return Arrays.stream(array)::iterator;
}
}
class WithImplicitConstructor {}
class WithExplicitConstructor { WithExplicitConstructor() {} }