Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 9 additions & 1 deletion src/checkers/inference/DefaultSlotManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ public Slot getVariableSlot( final AnnotatedTypeMirror atm ) {
*/
@Override
public Slot getSlot( final AnnotationMirror annotationMirror ) {
if (annotationMirror == null) {
return null;
}

final int id;
if (InferenceQualifierHierarchy.isVarAnnot(annotationMirror)) {
Expand Down Expand Up @@ -349,7 +352,12 @@ public RefinementVariableSlot createRefinementVariableSlot(AnnotationLocation lo
addToSlots(refinementVariableSlot);
} else if (locationCache.containsKey(location)) {
int id = locationCache.get(location);
refinementVariableSlot = (RefinementVariableSlot) getSlot(id);
if (getSlot(id) instanceof RefinementVariableSlot) {
refinementVariableSlot = (RefinementVariableSlot) getSlot(id);
} else {
refinementVariableSlot = new RefinementVariableSlot(location, nextId(), refined);
addToSlots(refinementVariableSlot);
}
} else {
refinementVariableSlot = new RefinementVariableSlot(location, nextId(), refined);
addToSlots(refinementVariableSlot);
Expand Down
5 changes: 5 additions & 0 deletions src/checkers/inference/InferenceQualifierHierarchy.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ public boolean isSubtype(final AnnotationMirror subtype, final AnnotationMirror

final Slot subSlot = slotMgr.getSlot(subtype);
final Slot superSlot = slotMgr.getSlot(supertype);

// TODO: remove hack
if (subSlot == null || superSlot == null) {
return true;
}

return constraintMgr.addSubtypeConstraintNoErrorMsg(subSlot, superSlot);
}
Expand Down
7 changes: 4 additions & 3 deletions src/checkers/inference/InferenceVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -658,9 +658,10 @@ public boolean maybeAddRefinementVariableConstraints(final AnnotatedTypeMirror v

Slot sub = slotManager.getVariableSlot(upperBound);
logger.fine("InferenceVisitor::commonAssignmentCheck: Equality constraint for qualifiers sub: " + sub + " sup: " + sup);

// Equality between the refvar and the value
constraintManager.addEqualityConstraint(sup, sub);
if (sub != null) {
// Equality between the refvar and the value
constraintManager.addEqualityConstraint(sup, sub);
}

// Refinement variable still needs to be a subtype of its declared type value
constraintManager.addSubtypeConstraint(sup, ((RefinementVariableSlot) sup).getRefined());
Expand Down
3 changes: 3 additions & 0 deletions src/checkers/inference/VariableAnnotator.java
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,9 @@ public boolean enclosedByAnnotation(TreePath path) {
treeKinds.add(Kind.METHOD);
treeKinds.add(Kind.CLASS);
Tree enclosure = TreeUtils.enclosingOfKind(path, treeKinds);
if (enclosure == null) {
return false;
}
return enclosure.getKind() == Kind.ANNOTATION
|| enclosure.getKind() == Kind.ANNOTATION_TYPE
|| enclosure.getKind() == Kind.TYPE_ANNOTATION;
Expand Down