mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-05 16:36:56 +07:00
The same was done for normal calls but not for method references Fixes IDEA-287197 "Constant conditions & exceptions": The "Suggest @Nullable annotation..." option no longer supports Objects::requireNonNull method references. GitOrigin-RevId: 42bf265d8ea1ce2a1ae1be519e2237e862e05492
30 lines
804 B
Java
30 lines
804 B
Java
import org.jetbrains.annotations.Nullable;
|
|
|
|
import java.util.Objects;
|
|
import java.util.stream.Stream;
|
|
|
|
class Main {
|
|
public static void main(String[] args) {
|
|
Stream.of("test1")
|
|
.map(Main::testNullableStaticMethod)
|
|
.map(Objects::requireNonNull);
|
|
|
|
Stream.of("test2")
|
|
.map(Main::testNullableStaticMethod)
|
|
.map(obj -> Objects.requireNonNull(obj));
|
|
|
|
Stream.of("test3")
|
|
.map(Main::testNullableStaticMethod)
|
|
.map(<warning descr="Method reference argument might be null but passed to non-annotated parameter">Main::requireNonNull</warning>);
|
|
}
|
|
|
|
static <T> T requireNonNull(T obj) {
|
|
if (obj == null) {
|
|
throw new NullPointerException();
|
|
}
|
|
return obj;
|
|
}
|
|
|
|
@Nullable
|
|
public static native String testNullableStaticMethod(String something);
|
|
} |