use of org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType in project checker-framework by typetools.
the class AtmLubVisitor method visitIntersection_Intersection.
@Override
public Void visitIntersection_Intersection(AnnotatedIntersectionType type1, AnnotatedIntersectionType type2, AnnotatedTypeMirror lub) {
AnnotatedIntersectionType castedLub = castLub(type1, lub);
lubPrimaryAnnotations(type1, type2, lub);
for (int i = 0; i < lub.directSuperTypes().size(); i++) {
AnnotatedDeclaredType lubST = castedLub.directSuperTypes().get(i);
visit(type1.directSuperTypes().get(i), type2.directSuperTypes().get(i), lubST);
}
return null;
}
use of org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType in project checker-framework by typetools.
the class InitializationAnnotatedTypeFactory method setSelfTypeInInitializationCode.
protected void setSelfTypeInInitializationCode(Tree tree, AnnotatedDeclaredType selfType, TreePath path) {
ClassTree enclosingClass = TreeUtils.enclosingClass(path);
Type classType = ((JCTree) enclosingClass).type;
AnnotationMirror annotation = null;
// there might still be subclasses that need initialization.
if (areAllFieldsCommittedOnly(enclosingClass)) {
Store store = getStoreBefore(tree);
if (store != null) {
List<AnnotationMirror> annos = Collections.emptyList();
if (getUninitializedInvariantFields(store, path, false, annos).size() == 0) {
if (classType.isFinal()) {
annotation = COMMITTED;
} else if (useFbc) {
annotation = createFreeAnnotation(classType);
} else {
annotation = createUnclassifiedAnnotation(classType);
}
}
}
}
if (annotation == null) {
annotation = getFreeOrRawAnnotationOfSuperType(classType);
}
selfType.replaceAnnotation(annotation);
}
use of org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType in project checker-framework by typetools.
the class InitializationAnnotatedTypeFactory method getSelfType.
@Override
public AnnotatedDeclaredType getSelfType(Tree tree) {
AnnotatedDeclaredType selfType = super.getSelfType(tree);
TreePath path = getPath(tree);
Tree topLevelMember = findTopLevelClassMemberForTree(path);
if (topLevelMember != null) {
if (topLevelMember.getKind() != Kind.METHOD || TreeUtils.isConstructor((MethodTree) topLevelMember)) {
setSelfTypeInInitializationCode(tree, selfType, path);
}
}
return selfType;
}
use of org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType in project checker-framework by typetools.
the class CollectionToArrayHeuristics method isNonNullReceiver.
/**
* Returns {@code true} if the method invocation tree receiver is collection who is known to
* contain non-null elements (i.e. its type argument is a {@code NonNull}.
*/
private boolean isNonNullReceiver(MethodInvocationTree tree) {
// check receiver
AnnotatedTypeMirror receiver = atypeFactory.getReceiverType(tree);
AnnotatedDeclaredType collection = AnnotatedTypes.asSuper(atypeFactory, receiver, collectionType);
if (collection.getTypeArguments().isEmpty() || !collection.getTypeArguments().get(0).hasEffectiveAnnotation(atypeFactory.NONNULL)) {
return false;
}
return true;
}
use of org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType in project checker-framework by typetools.
the class KeyForPropagationTreeAnnotator method visitVariable.
/**
* Transfers annotations to the variableTree if the right side is a call to
* java.util.Map.KeySet.
*/
@Override
public Void visitVariable(VariableTree variableTree, AnnotatedTypeMirror type) {
super.visitVariable(variableTree, type);
// This should only happen on map.keySet();
if (type.getKind() == TypeKind.DECLARED) {
final ExpressionTree initializer = variableTree.getInitializer();
if (isCallToKeyset(initializer)) {
final AnnotatedDeclaredType variableType = (AnnotatedDeclaredType) type;
final AnnotatedTypeMirror initializerType = atypeFactory.getAnnotatedType(initializer);
// array types and boxed primitives etc don't require propagation
if (variableType.getKind() == TypeKind.DECLARED) {
keyForPropagator.propagate((AnnotatedDeclaredType) initializerType, variableType, PropagationDirection.TO_SUPERTYPE, atypeFactory);
}
}
}
return null;
}
Aggregations