typetools / typetools/checker-framework
Nullness Checker error message uses incorrect parameter name
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
Test case:
import org.checkerframework.checker.nullness.qual.Nullable;
class Test {
interface A<T1 extends @Nullable Object> {
String fn(T1 o);
}
static String foo(Object o) { return o.toString(); }
static void testPositive() {
A<@Nullable Object> p = Test::foo;
}
}
Error output from the Nullness Checker:
/tmp/Test.java:8: error: [methodref.param] Incompatible parameter type for o
A<@Nullable Object> p = Test::foo;
^
found : @Initialized @NonNull Object
required: @Initialized @Nullable Object
Consequence: method in @Initialized @NonNull Test
@Initialized @NonNull String foo(@Initialized @NonNull Object p0)
is not a valid method reference for method in @UnknownInitialization @Nullable A<@Initialized @Nullable Object>
@Initialized @NonNull String fn(@Initialized @NonNull A<@Initialized @Nullable Object> this, @Initialized @Nullable Object p0)
1 error
In a couple of places the error message refers to p0 which is not the name of any variable in the program.
I also find the error message somewhat hard to read with all the (irrelevant) initializer annotations, but perhaps that is a separate issue.
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
Reproduce the diagnostic with the provided Test.java method-reference example and inspect how the Nullness Checker constructs the methodref.param error. Trace where parameter names become p0 instead of the source name o. Done means the diagnostic identifies the correct parameter name and the regression case passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100