Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSpecify: infer @Nullable type arguments for type variables from unmarked code #1178

Closed
msridhar opened this issue Mar 26, 2025 · 0 comments · Fixed by #1181
Closed

JSpecify: infer @Nullable type arguments for type variables from unmarked code #1178

msridhar opened this issue Mar 26, 2025 · 0 comments · Fixed by #1181

Comments

@msridhar
Copy link
Collaborator

msridhar commented Mar 26, 2025

Example:

@NullMarked
class SampleNullUnmarkedCall {

  @NullUnmarked
  static class Foo<T> {
    Foo(T t) {}

    static <U> Foo<U> id(U u) { return new Foo<>(u); }
  }

  static void test() {
    // should report no error
    Foo<@Nullable Object> x = Foo.id(null);
  }
}

Here, since Foo is @NullUnmarked, we can infer @Nullable Object as the type argument for the Foo.id(null) call, even though U (and T) do not have explicit @Nullable upper bounds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant