typetools / typetools/checker-framework
Improve type.incompatible error messages for wildcards
Open
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
Compiling the following code:
import java.util.*;
import org.checkerframework.checker.nullness.qual.*;
public class Issue520 {
}
abstract class Parent<T> {
protected final List<? super @KeyForBottom T> list;
public Parent(List<? super @KeyForBottom T> list) {
this.list = list;
}
}
abstract class Child extends Parent<CharSequence> {
public Child(List<? super CharSequence> list) {
super(list);
}
public void add(CharSequence seq) {
list.add(seq);
}
}
with the Nullness Checker issues the following error:
Issue520.java:26: error: [argument.type.incompatible] incompatible types in argument.
list.add(seq);
^
found : @UnknownKeyFor CharSequence
required: ? extends @UnknownKeyFor Object super @KeyForBottom CharSequence
1 error
That found type is within that required range, so no error should be issued.
A test case appears as file
checker-framework/checker/tests/nullness/Issue520.java
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 checker/tests/nullness/Issue520.java and run the Nullness Checker test for it. Trace the [argument.type.incompatible] diagnostic produced for list.add(seq), then make the wildcard case pass without reporting an error and verify the test succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100