diff --git a/src/checkers/inference/DefaultSlotManager.java b/src/checkers/inference/DefaultSlotManager.java index 0b7993010..c9017d271 100644 --- a/src/checkers/inference/DefaultSlotManager.java +++ b/src/checkers/inference/DefaultSlotManager.java @@ -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)) { @@ -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); diff --git a/src/checkers/inference/InferenceQualifierHierarchy.java b/src/checkers/inference/InferenceQualifierHierarchy.java index 5d0f535bd..1a46fb90d 100644 --- a/src/checkers/inference/InferenceQualifierHierarchy.java +++ b/src/checkers/inference/InferenceQualifierHierarchy.java @@ -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); } diff --git a/src/checkers/inference/InferenceVisitor.java b/src/checkers/inference/InferenceVisitor.java index 2914c6f01..0ddeed9ba 100644 --- a/src/checkers/inference/InferenceVisitor.java +++ b/src/checkers/inference/InferenceVisitor.java @@ -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()); diff --git a/src/checkers/inference/VariableAnnotator.java b/src/checkers/inference/VariableAnnotator.java index 1dc7e511b..14b953c1f 100644 --- a/src/checkers/inference/VariableAnnotator.java +++ b/src/checkers/inference/VariableAnnotator.java @@ -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;