Similar to #570, but not stream-specific.
We've hit this scenario 3 or 4 times in chrome so far:
import org.jspecify.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
@NullMarked
public class Foo {
@Nullable Object mThing;
void method(Object a, @Nullable Object b) {
mThing = new Object();
Runnable r = () -> mThing.hashCode();
r.run();
}
}
Foo.java:10: warning: [NullAway] dereferenced expression mThing is @Nullable
Runnable r = () -> mThing.hashCode();
^
(see http://t.uber.com/nullaway )
- When the field in question starts as null, but has only non-null assignments, then it is safe to assume it is non-null for dereferences that occur after an assignment (since it can never return to being null).
- For lambdas that are constructed after an assignment, we should not warn about dereferences made by lambdas.