Skip to content

JSpecify: missing warning with inner classes and inheritance #1274

Closed

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    jspecifylowpriority

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions