use of org.checkerframework.framework.qual.IgnoreInWholeProgramInference in project checker-framework by typetools.
the class WholeProgramInferenceScenes method updateInferredFieldType.
/**
* Updates the type of the field lhs in the Scene of the class with tree classTree. If the field
* has a declaration annotation with the {@link IgnoreInWholeProgramInference} meta-annotation,
* no type annotation will be inferred for that field.
*
* <p>If the Scene contains no entry for the field lhs, the entry will be created and its type
* will be the type of rhs. If the Scene previously contained an entry/type for lhs, its new
* type will be the LUB between the previous type and the type of rhs.
*
* <p>
*
* @param lhs the field whose type will be refined
* @param rhs the expression being assigned to the field
* @param classTree the ClassTree for the enclosing class of the assignment
* @param atf the annotated type factory of a given type system, whose type hierarchy will be
* used to update the field's type
*/
@Override
public void updateInferredFieldType(FieldAccessNode lhs, Node rhs, ClassTree classTree, AnnotatedTypeFactory atf) {
ClassSymbol classSymbol = getEnclosingClassSymbol(classTree, lhs);
// https://github.com/typetools/checker-framework/issues/682
if (classSymbol == null) {
// TODO: Handle anonymous classes.
return;
}
// https://github.com/typetools/checker-framework/issues/682
if (!classSymbol.getEnclosedElements().contains((Symbol) lhs.getElement())) {
return;
}
// @IgnoreInWholeProgramInference meta-annotation, exit this routine.
for (AnnotationMirror declAnno : atf.getDeclAnnotations(TreeUtils.elementFromTree(lhs.getTree()))) {
if (AnnotationUtils.areSameByClass(declAnno, IgnoreInWholeProgramInference.class)) {
return;
}
Element elt = declAnno.getAnnotationType().asElement();
if (elt.getAnnotation(IgnoreInWholeProgramInference.class) != null) {
return;
}
}
String className = classSymbol.flatname.toString();
String jaifPath = helper.getJaifPath(className);
AClass clazz = helper.getAClass(className, jaifPath);
AField field = clazz.fields.vivify(lhs.getFieldName());
AnnotatedTypeMirror lhsATM = atf.getAnnotatedType(lhs.getTree());
AnnotatedTypeMirror rhsATM = atf.getAnnotatedType(rhs.getTree());
helper.updateAnnotationSetInScene(field.type, atf, jaifPath, rhsATM, lhsATM, TypeUseLocation.FIELD);
}
Aggregations