Class MethodValAnnotatedTypeFactory.MethodValQualifierHierarchy
- Enclosing class:
MethodValAnnotatedTypeFactory
-
Field Summary
Fields inherited from class org.checkerframework.framework.type.ElementQualifierHierarchy
bottoms, bottomsMap, elements, elementToQualifierKind, kindToElementlessQualifier, qualifierKindHierarchy, tops, topsMapFields inherited from class org.checkerframework.framework.type.QualifierHierarchy
atypeFactory -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMethodValQualifierHierarchy(Collection<Class<? extends Annotation>> qualifierClasses, Elements elements) Creates a MethodValQualifierHierarchy from the given classes. -
Method Summary
Modifier and TypeMethodDescriptionReturns the greatest lower bound for the qualifiers qualifier1 and qualifier2.booleanisSubtypeQualifiers(AnnotationMirror subAnno, AnnotationMirror superAnno) Returns true ifsubQualifieris equal to or a sub-qualifier ofsuperQualifier, according to the type qualifier hierarchy, ignoring Java basetypes.Returns the least upper bound (LUB) of the qualifiersqualifier1andqualifier2.Methods inherited from class org.checkerframework.framework.type.ElementQualifierHierarchy
createBottomsMap, createElementlessQualifierMap, createElementToQualifierKindMap, createQualifierKindHierarchy, createTopsMap, findAnnotationInHierarchy, findAnnotationInSameHierarchy, getBottomAnnotation, getBottomAnnotations, getPolymorphicAnnotation, getQualifierKind, getQualifierKind, getTopAnnotation, getTopAnnotations, isPolymorphicQualifier, isValidMethods inherited from class org.checkerframework.framework.type.QualifierHierarchy
assertSameSize, assertSameSize, canHaveEmptyAnnotationSet, getParametricQualifier, getPolymorphicAnnotations, getWidth, greatestLowerBoundQualifiersOnly, greatestLowerBoundShallow, greatestLowerBoundsQualifiersOnly, greatestLowerBoundsQualifiersOnly, greatestLowerBoundsShallow, isBottom, isParametricQualifier, isSubtypeQualifiersOnly, isSubtypeQualifiersOnly, isSubtypeShallow, isSubtypeShallow, isSubtypeShallow, isSubtypeShallow, isTop, leastUpperBoundQualifiersOnly, leastUpperBoundShallow, leastUpperBoundsQualifiersOnly, leastUpperBoundsQualifiersOnly, leastUpperBoundsShallow, numberOfIterationsBeforeWidening, updateMappingToMutableSet, widenedUpperBound
-
Constructor Details
-
MethodValQualifierHierarchy
protected MethodValQualifierHierarchy(Collection<Class<? extends Annotation>> qualifierClasses, Elements elements) Creates a MethodValQualifierHierarchy from the given classes.- Parameters:
qualifierClasses- classes of annotations that are the qualifiers for this hierarchyelements- element utils
-
-
Method Details
-
leastUpperBoundQualifiers
public @Nullable AnnotationMirror leastUpperBoundQualifiers(AnnotationMirror a1, AnnotationMirror a2) Description copied from class:QualifierHierarchyReturns the least upper bound (LUB) of the qualifiersqualifier1andqualifier2. Returnsnullif the qualifiers are not from the same qualifier hierarchy. Ignores Java basetypes.Examples:
- For NonNull, leastUpperBound('Nullable', 'NonNull') ⇒ Nullable
Must stay consistent with
QualifierHierarchy.isSubtypeQualifiers(javax.lang.model.element.AnnotationMirror, javax.lang.model.element.AnnotationMirror): the result must be a supertype of bothqualifier1andqualifier2, and a subtype of every other common supertype of the two (i.e., the least such supertype). SeeQualifierHierarchy.isSubtypeQualifiers(javax.lang.model.element.AnnotationMirror, javax.lang.model.element.AnnotationMirror)'s documentation for why this matters even for a qualifier hierarchy whose true subtyping relation is not fully expressible as a static, declarative lattice.- Specified by:
leastUpperBoundQualifiersin classQualifierHierarchy- Parameters:
a1- the first qualifier; may not be in the same hierarchy asqualifier2a2- the second qualifier; may not be in the same hierarchy asqualifier1- Returns:
- the least upper bound of the qualifiers, or
nullif the qualifiers are from different hierarchies
-
greatestLowerBoundQualifiers
public @Nullable AnnotationMirror greatestLowerBoundQualifiers(AnnotationMirror a1, AnnotationMirror a2) Description copied from class:QualifierHierarchyReturns the greatest lower bound for the qualifiers qualifier1 and qualifier2. Returns null if the qualifiers are not from the same qualifier hierarchy.Must stay consistent with
QualifierHierarchy.isSubtypeQualifiers(javax.lang.model.element.AnnotationMirror, javax.lang.model.element.AnnotationMirror): the result must be a subtype of bothqualifier1andqualifier2, and a supertype of every other common subtype of the two (i.e., the greatest such subtype). SeeQualifierHierarchy.isSubtypeQualifiers(javax.lang.model.element.AnnotationMirror, javax.lang.model.element.AnnotationMirror)'s documentation for why this matters even for a qualifier hierarchy whose true subtyping relation is not fully expressible as a static, declarative lattice.- Specified by:
greatestLowerBoundQualifiersin classQualifierHierarchy- Parameters:
a1- first qualifiera2- second qualifier- Returns:
- greatest lower bound of the two annotations, or null if the two annotations are not from the same hierarchy
-
isSubtypeQualifiers
Description copied from class:QualifierHierarchyReturns true ifsubQualifieris equal to or a sub-qualifier ofsuperQualifier, according to the type qualifier hierarchy, ignoring Java basetypes.Clients should generally call
QualifierHierarchy.isSubtypeShallow(javax.lang.model.element.AnnotationMirror, javax.lang.model.type.TypeMirror, javax.lang.model.element.AnnotationMirror, javax.lang.model.type.TypeMirror). However, subtypes should generally override this method (if needed).This method behaves the same as
QualifierHierarchy.isSubtypeQualifiersOnly(AnnotationMirror, AnnotationMirror), which calls this method. This method is for clients inside the framework, and it hasprotectedaccess to prevent use by clients outside the framework. This makes it easy to find places where code outside the framework is ignoring Java basetypes -- at calls toQualifierHierarchy.isSubtypeQualifiersOnly(javax.lang.model.element.AnnotationMirror, javax.lang.model.element.AnnotationMirror).An override must stay consistent with
QualifierHierarchy.leastUpperBoundQualifiers(javax.lang.model.element.AnnotationMirror, javax.lang.model.element.AnnotationMirror)andQualifierHierarchy.greatestLowerBoundQualifiers(javax.lang.model.element.AnnotationMirror, javax.lang.model.element.AnnotationMirror): for any two qualifiersaandbin the same hierarchy,leastUpperBoundQualifiers(a, b)must be a supertype of bothaandbunder this method and a subtype of every other common supertype of the two (i.e., the least such supertype, not merely some upper bound);greatestLowerBoundQualifiers(a, b)must be a subtype of both and a supertype of every other common subtype of the two (i.e., the greatest such subtype). This matters even for a qualifier hierarchy whose true subtyping relation is not fully expressible as a static, declarative lattice (for example, one that depends on a checker option such as a strict/lenient mode): if this method special-cases such a situation butQualifierHierarchy.leastUpperBoundQualifiers(javax.lang.model.element.AnnotationMirror, javax.lang.model.element.AnnotationMirror)/QualifierHierarchy.greatestLowerBoundQualifiers(javax.lang.model.element.AnnotationMirror, javax.lang.model.element.AnnotationMirror)do not, a caller that combines qualifiers with one and later checks the result with the other -- asAnnotatedTypeFactory.combineIntersectionBoundAnnotationsInHierarchy(javax.lang.model.element.AnnotationMirror, javax.lang.model.element.AnnotationMirror, org.checkerframework.framework.type.QualifierHierarchy)does when overridden to return a greatest lower bound -- can derive a summary that this method would not itself have accepted, producing a spurious type error where none existed before the summary was combined.- Specified by:
isSubtypeQualifiersin classQualifierHierarchy- Parameters:
subAnno- possible subqualifiersuperAnno- possible superqualifier- Returns:
- true iff
subQualifieris a subqualifier of, or equal to,superQualifier
-