You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Thanks for the report. This doesn't work because we need to run a dataflow analysis within the lambda body to figure out that s == null ? null : s is in fact @Nullable. We haven't quite implemented that properly yet. FYI @dhruv-agr
Activity
msridhar commentedon Dec 10, 2025
Thanks for the report. This doesn't work because we need to run a dataflow analysis within the lambda body to figure out that
s == null ? null : sis in fact@Nullable. We haven't quite implemented that properly yet. FYI @dhruv-agrChange how recursive calls to dataflow are detected (#1374)
Run dataflow analysis on bodies of lambdas passed to generic methods (a…