typetools / typetools/checker-framework
False positive error with a <?> wildcard type assigned to var
Open
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
Commands
java -version -Aversion -AprintGitProperties -verbose -AprintVerboseGenerics
java -jar "$CHECKER_FRAMEWORK/checker/dist/checker.jar" -processor nullness Foo.java
Inputs
A single input named Foo.java:
interface Foo<T>{
}
record Bar(Foo<?> foo) {
void bazz() {
var clazz = foo.getClass();
}
}
Outputs
openjdk version "17.0.11" 2024-04-16
OpenJDK Runtime Environment (build 17.0.11+9-Ubuntu-122.04.1)
OpenJDK 64-Bit Server VM (build 17.0.11+9-Ubuntu-122.04.1, mixed mode, sharing)
error: [type.argument] incompatible type argument for type parameter T of Class.
found : capture#01[ extends @UnknownKeyFor Foo</*RAW TYPE ARGUMENT:*/ ?[ extends @UnknownKeyFor Object super @UnknownKeyFor Void]> super @KeyForBottom Void]
required: [extends @UnknownKeyFor Object super @UnknownKeyFor NullType]
1 error
Expectation
No error, like in
interface Foo<T>{
}
record Bar(Foo<?> foo) {
void bazz() {
Class<?> clazz = foo.getClass();
}
}
case.
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 report with the supplied Foo.java input and the nullness processor command. Trace how the checker handles foo.getClass() when foo has a wildcard type and var infers the result. Done means the example produces no type.argument error while preserving the reported explicit Class<?> case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100