Skip to content

Nullability of generics ignored for extended interfaces #1252

@agrieve

Description

@agrieve

Not sure if this is the same as #1246, but:

import org.chromium.build.annotations.NullMarked;
import org.chromium.build.annotations.Nullable;

@NullMarked
class Foo {
  static interface Base<T extends @Nullable Object> {}
  static interface Sub<T> extends Base<@Nullable T> {}

  static void foo(Base<@Nullable Object> arg) {}
  static void bar(Sub<Object> arg) {
    foo(arg);
  }
}
Foo.java:11: warning: [NullAway] Cannot pass parameter of type Sub<Object>, as formal parameter has type Base<@Nullable Object>, which has mismatched type parameter nullability
    foo(arg);
        ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugjspecifyRelated to support for jspecify standard (see jspecify.dev)

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions