typetools / typetools/checker-framework
Confusing qualifier in "required" line of error message
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.*;
class Test {
void foo(Object nn, @Nullable Object nbl) {
var l = new ArrayList<String>();
l = new ArrayList<@Nullable String>();
}
}
When I check the code with the Nullness Checker, I get the error:
Test.java:6: error: [assignment] incompatible types in assignment.
l = new ArrayList<@Nullable String>();
^
found : @Initialized @NonNull ArrayList<@Initialized @Nullable String>
required: @UnknownInitialization @Nullable ArrayList<@Initialized @NonNull String>
1 error
In the "required" line I find @Nullable ArrayList to be confusing. I guess @Nullable is written since it would be ok to assign null here, since we infer the type of local l? The real issue though is that the type argument needs to be @NonNull.
Possibly related to #2276
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 reproducing the supplied Test.java example with the Nullness Checker and inspect how the assignment diagnostic formats its found and required types. Determine wording that makes the nullable outer type and non-null element type distinction clear, then verify the revised diagnostic with the example.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100