Skip to content

JSpecify: missing warning with inner classes and inheritance #1274

@msridhar

Description

@msridhar
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
@NullMarked
public class Test {
  class A<X extends @Nullable Object> {
    class B<Y extends @Nullable Object> {}
  }
  class C<X extends @Nullable Object> extends A<X> {
    class D<Y extends @Nullable Object> extends A<X>.B<Y> {}
  }
  void test() {
    C<@Nullable String> c = new C<>();
    A<String>.B<@Nullable String> unused = c.new D<@Nullable String>();
  }
}

We should warn at the final assignment due to incompatibility between A<String> and C<@Nullable String> but we currently do not. I think this is low priority compared to other open JSpecify issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    jspecifyRelated to support for jspecify standard (see jspecify.dev)lowpriority

    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