typetools / typetools/checker-framework
failed to report type argument that does not satisfy upper bound
@smillst is already working on this.
Since Oct 23, 2024.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
Command
javac -J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
-J--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED \
-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED \
-J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED \
-J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED \
-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED \
-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED \
-processor org.checkerframework.checker.nullness.NullnessChecker \
-cp ~/projects/checker-framework/checker/dist/checker.jar -Aignorejdkastub Test.java
File
import org.checkerframework.checker.nullness.qual.*;
class A<T extends Number> {}
public class Test {
public static <T> T bottom() { throw new RuntimeException(); }
public static A<? extends Number> test() {
return (true) ?
Test.<A<@Nullable Number>>bottom() :
Test.<A<@Nullable Number>>bottom();
}
}
Actual behavior
The code passes the checks although @Nullable Integer is not a valid subtype of T extends Number.
I attempted to create a reproducible test case that triggers a NullPointerException due to this mismatch, but I was unable to do so. This suggests that, in practice, the issue might not cause immediate problems.
However, I decided to report this issue in case the underlying root cause could manifest itself through different symptoms in other scenarios.
Expected behavior
The code should have been rejected as @Nullable Integer is not a valid subtype of T extends Number.
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.
Assessment
This issue has not been assessed yet.