diff --git a/src/checkers/inference/VariableAnnotator.java b/src/checkers/inference/VariableAnnotator.java index 693086513..99bfee5c3 100644 --- a/src/checkers/inference/VariableAnnotator.java +++ b/src/checkers/inference/VariableAnnotator.java @@ -500,6 +500,10 @@ private VariableSlot addPrimaryVariable(AnnotatedTypeMirror atm, final Tree tree if (variable.getLocation() == null) { variable.setLocation(treeToLocation(tree)); } + if (variable instanceof ConstantSlot) { + atm.removeAnnotation(((ConstantSlot) variable).getValue()); + } + atm.replaceAnnotation(slotManager.getAnnotation(variable)); } else { AnnotationLocation location = treeToLocation(tree); variable = replaceOrCreateEquivalentVarAnno(atm, tree, location); @@ -509,9 +513,6 @@ private VariableSlot addPrimaryVariable(AnnotatedTypeMirror atm, final Tree tree treeToVarAnnoPair.put(tree, varATMPair); } - - atm.replaceAnnotation(slotManager.getAnnotation(variable)); - return variable; } @@ -566,7 +567,9 @@ private VariableSlot replaceOrCreateEquivalentVarAnno(AnnotatedTypeMirror atm, T } else { varSlot = createVariable(location); } - + if (realQualifier != null) { + atm.removeAnnotation(realQualifier); + } atm.replaceAnnotation(slotManager.getAnnotation(varSlot)); return varSlot; }