NullAway
NullAway copied to clipboard
Wrong class name used in error message when "this" is used in an anonymous inner class
@NullMarked
class Foo {
interface Callback<T extends @Nullable Object> {
void onResult(T result);
}
static void addCallback(Callback<@Nullable Integer> cb) {
}
static void removeCallback(Callback<@Nullable Integer> cb) {
}
public void main() {
addCallback(new Callback<>() {
@Override
public void onResult(Integer value) {
removeCallback(this);
}
});
}
}
This results in:
Foo.java:21: warning: [NullAway] Cannot pass parameter of type Foo., as formal parameter has type Callback<@Nullable Integer>, which has mismatched type parameter nullability
removeCallback(this);
^
(see http://t.uber.com/nullaway )
Note that "Foo" is the outer class, but the class it's complaining about is the anonymous Callback.
If you change main() to be static, it shows:
Foo.java:21: warning: [NullAway] Cannot pass parameter of type , as formal parameter has type Callback<@Nullable Integer>, which has mismatched type parameter nullability
removeCallback(this);
^
(see http://t.uber.com/nullaway )