typetools / typetools/checker-framework

Incorrect annotations on enclosing type type parameters

Open
#3,983 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

False Positive (false warning or imprecision)
Dominant language
Java
Stars
1.1k
Forks
440
Avg merge
1d 12h
Merged PRs (30d)
134

Description

@SuppressWarnings("initialization.fields.uninitialized")
public abstract class EnclosingType<T extends @Nullable Number> {
    abstract class Inner{
        abstract T get();
        abstract void set(T t);
    }
    Inner i;
    T t;
    void setI(Inner i) {
        i.set(this.i.get());  // error here
    }
}

I expected no error, but the following was issued:

error: [argument.type.incompatible] incompatible argument for parameter t of set.
        i.set(this.i.get());
                        ^
  found   : T[ extends @Initialized @Nullable Number super @Initialized @NonNull Void]
  required: T[ extends @Initialized @NonNull Number super @Initialized @NonNull Void]

The explicit annotation on the bound of T is ignored.

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.

Research direction

Start with the Java reproducer in the issue and trace how the Checker Framework processes the @Nullable bound on EnclosingType. Identify the type-annotation handling responsible for the mismatch, then verify that i.set(this.i.get()) is accepted without changing unrelated diagnostics.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.