typetools / typetools/checker-framework
Failing constraint printed twice for `type.arguments.not.inferred` error
Open
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
Example:
import java.util.*;
import org.checkerframework.checker.nullness.qual.*;
class Test {
public static <T extends @Nullable Object> T firstOrDefault(List<T> list, T defaultValue) {
return list.isEmpty() ? defaultValue : list.get(0);
}
public static <U extends @Nullable Object> List<U> singletonList(U o) {
throw new RuntimeException();
}
String field = firstOrDefault(singletonList(null), "hello");
}
Nullness Checker output:
$ path/to/checker/bin/javac -processor nullness Test.java
Test.java:13: error: [assignment] incompatible types in assignment.
String field = firstOrDefault(singletonList(null), "hello");
^
found : @Initialized @Nullable String
required: @Initialized @NonNull String
Test.java:13: error: [type.arguments.not.inferred] Could not infer type arguments for Test.firstOrDefault
String field = firstOrDefault(singletonList(null), "hello");
^
unsatisfiable constraint: @org.checkerframework.checker.nullness.qual.Nullable <: @org.checkerframework.checker.nullness.qual.NonNull
@org.checkerframework.checker.nullness.qual.Nullable <: @org.checkerframework.checker.nullness.qual.NonNull
2 errors
The unsat constraint @org.checkerframework.checker.nullness.qual.Nullable <: @org.checkerframework.checker.nullness.qual.NonNull is printed twice.
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 Java example with the Nullness Checker and compare the two diagnostics for type.arguments.not.inferred. Trace the diagnostic-generation entry point for that error and identify where the unsatisfiable constraint is emitted more than once. Done means the constraint appears once while the relevant errors remain correctly reported.
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
- 48/100