Bug for Defaulting Type Variable Upper Bounds
On my fork, I'm working on a checker, for which all defaults must be bottom (as a first step). The bottom type qualifier is annotated to be the default for upper bounds.
@DefaultFor({
...
TypeUseLocation.UPPER_BOUND
...
})
However, running this checker on the cf results in an error. Specifically,
gradlew :framework:checkResourceLeak
fails because a type var upper bound wrongly defaults to TOP. The failure occurs in InitializedFieldsAnnotatedTypeFactory.java. Running the checker on this file alone cannot reproduce the error, but compiling it together with GenericAnnotatedTypeFactory.java does. I minimized both files while still being able to replicate the error.
How to reproduce:
- clone my cf fork:
git clone https://github.com/skehrli/checker-framework - cd into the fork directory:
cd /path/to/my/fork - checkout to feature branch:
git checkout rlc-collections-redesign - extract binaries for maven:
gradlew publishToMavenLocal - clone repo with test case:
git clone https://github.com/skehrli/test - cd into the dir:
cd /path/to/skehrli/test - run:
mvn compile
This compiles the two files together. When GenericAnnotatedTypeFactory.java is removed from the src dir and only InitializedFieldsAnnotatedTypeFactory.java is compiled, it completes without errors.
You need to remove the override of createQualifierHierarchy in CollectionOwnershipAnnotatedTypeFactory. The default implementation is correct for this hierarchy. CollectionOwnershipQualifierHierarchy is implemented incorrectly and should just be deleted.
CollectionOwnershipAnnotatedTypeFactory.this.TOP.getClass() returns the class of the AnnotationMirror, which is CheckerFrameworkAnnotationMirror (org.checkerframework.javacutil.AnnotationUtils#annotationName is return the fully qualified class name.)
Thanks a lot! This resolved it.