-
Notifications
You must be signed in to change notification settings - Fork 331
Lambda parameter confuses #1373
Copy link
Copy link
Closed
Labels
bugjspecifyRelated to support for jspecify standard (see jspecify.dev)Related to support for jspecify standard (see jspecify.dev)
Description
import org.chromium.build.annotations.NullMarked;
import org.chromium.build.annotations.Nullable;
@NullMarked
class Foo {
interface Func<ParamT extends @Nullable Object, RetT extends @Nullable Object> {
RetT apply(ParamT p);
}
public static <RetT extends @Nullable Object> RetT run(Func<String, RetT> func) {
return func.apply("");
}
static void repro() {
run(s -> s == null ? null : s);
}
}
give:
Foo.java:16: warning: [NullAway] returning @Nullable expression from method with @NonNull return type
run(s -> s == null ? null : s);
^
(see http://t.uber.com/nullaway )
The return type is <RetT extends @Nullable Object>, so null should be fine.
Interestingly, this lambda does not emit a warning:
run(s -> null, "");
Using a subclass rather than a lambda also does not emit a warning.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugjspecifyRelated to support for jspecify standard (see jspecify.dev)Related to support for jspecify standard (see jspecify.dev)