mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-21 17:52:27 +07:00
Fixes IDEA-375416 False-positive nullability report on lambda with ternary and null in one branch GitOrigin-RevId: 5679bb57205cb4d49b9e87cbc4b8236c30aced67
23 lines
608 B
Java
23 lines
608 B
Java
import org.jspecify.annotations.NullMarked;
|
|
|
|
import java.util.function.Function;
|
|
import java.util.List;
|
|
|
|
public class JSpecifyLambdaTernary {
|
|
static <T, R> R process(List<T> list, Function<? super T, ? extends R> fn) {
|
|
return fn.apply(list.get(0));
|
|
}
|
|
|
|
@NullMarked
|
|
static class Use {
|
|
static void processList(List<Integer> list) {
|
|
Integer result = process(list, s -> s == 0 ? null : s);
|
|
if (result == null) {}
|
|
}
|
|
|
|
static void processListNonNumeric(List<String> list) {
|
|
String result = process(list, s -> s.isEmpty() ? null : s);
|
|
if (result == null) {}
|
|
}
|
|
}
|
|
} |