typetools / typetools/checker-framework

Handling of obsolete declaration annotations on arrays where the element is a type parameter

Open
#6,374 0 comments 0 reactions 1 assignee View on GitHub

@smillst is already working on this.

Since Jan 17, 2024.

Dominant language
Java
Stars
1.1k
Forks
440
Avg merge
1d 12h
Merged PRs (30d)
134

Description

Is the behaviour below expected? Per https://checkerframework.org/manual/#declaration-annotations-moved, I thought the declaration annotation below would be treated as if I had written T @Nonnull... with an equivalent type annotation.

// lib/Lib.java
import javax.annotation.Nonnull;

public class Lib {
  static <T> void x(@Nonnull T... o) {}
}
// User.java
public class User {
  void go() {
    Lib.x("", null);
  }
}
$ ./checker-framework-3.42.0/checker/bin/javac -cp jsr305-3.0.2.jar lib/Lib.java -d out
$ ./checker-framework-3.42.0/checker/bin/javac -cp out -processor nullness User.java
User.java:3: error: [argument] incompatible argument for parameter arg0 of Lib.x.
    Lib.x("", null);
              ^
  found   : null (NullType)
  required: @Initialized @NonNull String
1 error

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.