typetools / typetools/checker-framework
Incorrect enclosing types
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
The following code should issue an error, but doesn't.
import org.checkerframework.checker.nullness.qual.Nullable;
public class Issue4853B {
interface Interface<Q> {}
static class MyClass<T> {
class InnerMyClass implements Interface<T> {}
}
abstract static class SubMyClass extends MyClass<@Nullable String> {
protected void f() {
// :: error: (assignment)
Interface<@Nullable String> callback = method(); // missing error here.
}
abstract InnerMyClass method();
}
}
The problem is the return type of method is MyClass<@NonNull String>.InnerMyClass where @NonNull is defaulted. Instead of defaulting, the enclosing type of InnerMyClass should be computed from the enclosing type of this. I would guess there are other place where the Checker Framework isn't computing the correct enclosing type.
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 with the Java reproducer in the issue and trace how the Checker Framework computes the return type of method() for the nested InnerMyClass. Verify that its enclosing type is derived from this rather than defaulted to @NonNull, and confirm that the shown assignment now produces the expected error.
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
- Mostly clear
- Newbie friendliness
- 45/100