typetools / typetools/checker-framework
Missing error on qualifiers on enclosing types.
Open
Nobody has claimed this yet.
False Negative (missing warning or unsoundness)
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
// A qualifier written on the type argument of an *enclosing* type is dropped. In
// `Gen<@Nullable String>.Inner`, the type variable `T` is instantiated with `@NonNull String`
// instead of `@Nullable String`.
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
public class EnclosingTypeArgAnno {
void useEnclosingTypeArg(Gen<@Nullable String>.Inner i, @Nullable String nble) {
// T is @Nullable String, so passing a @Nullable String is legal.
// The Checker Framework reports a false positive (argument) here.
i.use(nble);
@Nullable String s = i.get();
// T is @Nullable String, so this assignment is illegal.
// The Checker Framework misses this error.
// :: error: [assignment]
@NonNull String t = i.get();
}
// For contrast, the same qualifier on the type argument of a non-enclosing type is honored, and
// both of the diagnostics below are as expected.
void useOwnTypeArg(Box<@Nullable String> b, @Nullable String nble) {
b.use(nble);
@Nullable String s = b.get();
// :: error: [assignment]
@NonNull String t = b.get();
}
}
class Gen<T extends @Nullable Object> {
class Inner {
void use(T arg) {}
T get() {
throw new AssertionError();
}
}
}
class Box<T extends @Nullable Object> {
void use(T arg) {}
T get() {
throw new AssertionError();
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by compiling the supplied EnclosingTypeArgAnno reproducer with the Checker Framework and compare its diagnostics with the Box case. Trace how qualifiers on Gen<@Nullable String>.Inner are handled versus qualifiers on Box<@Nullable String>; done means the enclosing-type case accepts i.use(nble) and reports the annotated [assignment] error for t.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 65/100