-
Notifications
You must be signed in to change notification settings - Fork 329
Closed
Labels
Description
import org.chromium.build.annotations.NullMarked;
import org.chromium.build.annotations.Nullable;
import org.chromium.build.annotations.NonNull;
@NullMarked
class Foo {
interface MaybeNull<T extends @Nullable Object> {
T get();
default MaybeNull<@NonNull T> asNonNull() {
return (MaybeNull<@NonNull T>)this;
}
}
static void accept(MaybeNull<String> nonNullThing) {}
static void main() {
MaybeNull<@Nullable String> nullable = null;
accept(nullable.asNonNull());
}
}results in:
Foo.java:19: warning: [NullAway] incompatible types: MaybeNull<@Nullable String> cannot be converted to MaybeNull<String>
accept(nullable.asNonNull());
^
(see http://t.uber.com/nullaway )
I would expect MaybeNull<@NonNull T>to mean MaybeNull<T> when T is @Nullable.
msridhar