Files
openide/java/java-tests/testData/inspection/dataFlow/fixture/StreamFindFirstExpectNotNull.java
Tagir Valeev 67ae5c45e2 [java-dfa] Report when nullable value is passed to findFirst()
Fixes IDEA-289362 NPE could be detected on findFirst on a stream with nullable elements

GitOrigin-RevId: 2d27d29eacdb2612608060d423646184a9093f51
2022-02-25 11:10:31 +00:00

19 lines
506 B
Java

import org.jetbrains.annotations.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
class StreamTypeAnnoInlining {
@Nullable
private static Object fun(String s) {
return null;
}
void test() {
Stream.of("a", "b").map(s -> <warning descr="Function may return null, but it's not allowed here">fun(s)</warning>).findFirst();
Stream.of("a", "b").map(s -> <warning descr="Function may return null, but it's not allowed here">fun(s)</warning>).findAny();
}
}