Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions src/checkers/inference/InferenceAnnotatedTypeFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.checkerframework.framework.util.defaults.QualifierDefaults;
import org.checkerframework.framework.util.dependenttypes.DependentTypesHelper;
import org.checkerframework.javacutil.AnnotationBuilder;
import org.checkerframework.javacutil.AnnotationUtils;
import org.checkerframework.javacutil.BugInCF;
import org.checkerframework.javacutil.ElementUtils;
import org.checkerframework.javacutil.Pair;
Expand Down Expand Up @@ -570,10 +571,14 @@ protected InferenceViewpointAdapter createViewpointAdapter() {
*/
@Override
public Set<AnnotationMirror> getTypeDeclarationBounds(TypeMirror type) {
final TypeElement elt = (TypeElement) getProcessingEnv().getTypeUtils().asElement(type);
Comment thread
zcai1 marked this conversation as resolved.
AnnotationMirror vAnno = variableAnnotator.getClassDeclVarAnnot(elt);
if (vAnno != null) {
return Collections.singleton(vAnno);
final Element elt = getProcessingEnv().getTypeUtils().asElement(type);
AnnotationMirror vAnno;

if (elt instanceof TypeElement) {
vAnno = variableAnnotator.getClassDeclVarAnnot((TypeElement) elt);
if (vAnno != null) {
return Collections.singleton(vAnno);
}
}

// This is to handle the special case of anonymous classes when the super class (or interface)
Expand All @@ -590,7 +595,13 @@ public Set<AnnotationMirror> getTypeDeclarationBounds(TypeMirror type) {
}

// If the declaration bound of the underlying type is not cached, use default
return (Set<AnnotationMirror>) getDefaultTypeDeclarationBounds();
Set<AnnotationMirror> realBounds = realTypeFactory.getTypeDeclarationBounds(type);
Set<AnnotationMirror> boundsVarAnnos = AnnotationUtils.createAnnotationSet();
for (AnnotationMirror realBound : realBounds) {
Slot slot = slotManager.getSlot(realBound);
boundsVarAnnos.add(slotManager.getAnnotation(slot));
}
return boundsVarAnnos;
}

/**
Expand Down