Class AnnotatedTypeMirror.AnnotatedTypeVariable
- All Implemented Interfaces:
DeepCopyable<AnnotatedTypeMirror>
- Enclosing class:
AnnotatedTypeMirror
-
Nested Class Summary
Nested classes/interfaces inherited from class org.checkerframework.framework.type.AnnotatedTypeMirror
AnnotatedTypeMirror.AnnotatedArrayType, AnnotatedTypeMirror.AnnotatedDeclaredType, AnnotatedTypeMirror.AnnotatedExecutableType, AnnotatedTypeMirror.AnnotatedIntersectionType, AnnotatedTypeMirror.AnnotatedNoType, AnnotatedTypeMirror.AnnotatedNullType, AnnotatedTypeMirror.AnnotatedPrimitiveType, AnnotatedTypeMirror.AnnotatedTypeVariable, AnnotatedTypeMirror.AnnotatedUnionType, AnnotatedTypeMirror.AnnotatedWildcardType, AnnotatedTypeMirror.ErrorTypeKindException -
Field Summary
Fields inherited from class org.checkerframework.framework.type.AnnotatedTypeMirror
atypeFactory, EQUALITY_COMPARER, HASHCODE_VISITOR, primaryAnnotations, underlyingType -
Method Summary
Modifier and TypeMethodDescription<R,P> R accept(AnnotatedTypeVisitor<R, P> v, P p) Applies a visitor to this type.voidaddAnnotation(AnnotationMirror annotation) Adds the canonical version ofannotationas a primary annotation of this type and, in the case ofAnnotatedTypeMirror.AnnotatedTypeVariables,AnnotatedTypeMirror.AnnotatedWildcardTypes, andAnnotatedTypeMirror.AnnotatedIntersectionTypes, adds it to all bounds.asUse()voidRemoves all primary annotations on this type and, in the case ofAnnotatedTypeMirror.AnnotatedTypeVariables,AnnotatedTypeMirror.AnnotatedWildcardTypes, andAnnotatedTypeMirror.AnnotatedIntersectionTypes, clears all bounds too, matchingAnnotatedTypeMirror.addAnnotation(javax.lang.model.element.AnnotationMirror)andAnnotatedTypeMirror.removeAnnotation(javax.lang.model.element.AnnotationMirror), which already propagate to bounds for those three kinds.deepCopy()Returns a deep copy of this type with annotations.deepCopy(boolean copyAnnotations) Returns a deep copy of this type.Returns the upper and lower bound fields of this type variable directly, without forcing lazy initialization (the fields may be null).Returns the upper and lower bounds of this type variable, forcing their lazy initialization if necessary.This method will traverse the upper bound of this type variable calling getErased until it finds the concrete upper bound.getKind()Returns thekindof this type.Returns the lower bound type of this type variable.Returns the lower bound field directly, bypassing any lazy initialization.Returns the underlying unannotated Java type, which this wraps.Returns the upper bound of the type variable, possibly lazily initializing it.Returns the upper bound field directly, bypassing any lazy initialization.booleanReturns true if this type mirror represents a declaration, rather than a use, of a type.booleanRemoves a primary annotation from the type.voidsetDeclaration(boolean declaration) Change whether thisAnnotatedTypeVariableis considered a use or a declaration (use this method with caution).voidSet the lower bound of this variable type.voidSet the upper bound of this variable type.Returns a shallow copy of this type with annotations.shallowCopy(boolean copyAnnotations) Returns a shallow copy of this type.Methods inherited from class org.checkerframework.framework.type.AnnotatedTypeMirror
addAnnotations, addAnnotations, addMissingAnnotation, addMissingAnnotations, addMissingAnnotations, checkMutable, containsCapturedTypes, createType, createTypeOfObject, createTypeOfRecord, directSupertypes, equals, freeze, getAnnotation, getAnnotation, getAnnotationInHierarchy, getAnnotations, getAnnotationsField, getEffectiveAnnotation, getEffectiveAnnotationInHierarchy, getEffectiveAnnotations, getExplicitAnnotations, getPrimitiveKind, getUnderlyingTypeHashCode, hasAnnotation, hasAnnotation, hasAnnotationInHierarchy, hasAnnotationRelaxed, hasEffectiveAnnotation, hasEffectiveAnnotation, hasEffectiveAnnotationRelaxed, hasExplicitAnnotation, hasExplicitAnnotation, hasExplicitAnnotationRelaxed, hashCode, isFrozen, removeAnnotationByClass, removeAnnotationInHierarchy, removeAnnotations, replaceAnnotation, replaceAnnotations, replaceAnnotations, toString, toString
-
Method Details
-
getKind
Description copied from class:AnnotatedTypeMirrorReturns thekindof this type.Subclasses whose kind is constant (e.g.
AnnotatedTypeMirror.AnnotatedDeclaredType,AnnotatedTypeMirror.AnnotatedArrayType) override this to return the constant directly; this is meaningful for performance because the underlying javacType#getKind()on declared types runsSymbol#apiComplete. OnlyAnnotatedTypeMirror.AnnotatedPrimitiveTypeandAnnotatedTypeMirror.AnnotatedNoTypefall through to this base implementation; for both, the underlying type'sgetKind()is cheap and does not force symbol completion.- Overrides:
getKindin classAnnotatedTypeMirror- Returns:
- the kind of this type
-
isDeclaration
public boolean isDeclaration()Description copied from class:AnnotatedTypeMirrorReturns true if this type mirror represents a declaration, rather than a use, of a type.For example,
class List<T> { ... }declares a new typeList<T>, whileList<Integer>is a use of the type.- Overrides:
isDeclarationin classAnnotatedTypeMirror- Returns:
- true if this represents a declaration
-
addAnnotation
Description copied from class:AnnotatedTypeMirrorAdds the canonical version ofannotationas a primary annotation of this type and, in the case ofAnnotatedTypeMirror.AnnotatedTypeVariables,AnnotatedTypeMirror.AnnotatedWildcardTypes, andAnnotatedTypeMirror.AnnotatedIntersectionTypes, adds it to all bounds. (The canonical version is found viaAnnotatedTypeFactory.asSupportedQualifier(javax.lang.model.element.AnnotationMirror).) If the canonical version ofannotationis not a supported qualifier, then no annotation is added. If this type already has annotation in the same hierarchy asannotation, the behavior of this method is undefined.- Overrides:
addAnnotationin classAnnotatedTypeMirror- Parameters:
annotation- the annotation to add
-
removeAnnotation
Description copied from class:AnnotatedTypeMirrorRemoves a primary annotation from the type.- Overrides:
removeAnnotationin classAnnotatedTypeMirror- Parameters:
a- the annotation to remove- Returns:
- true if the annotation was removed, false if the type's annotations were unchanged
-
clearAnnotations
public void clearAnnotations()Removes all primary annotations on this type and, in the case ofAnnotatedTypeMirror.AnnotatedTypeVariables,AnnotatedTypeMirror.AnnotatedWildcardTypes, andAnnotatedTypeMirror.AnnotatedIntersectionTypes, clears all bounds too, matchingAnnotatedTypeMirror.addAnnotation(javax.lang.model.element.AnnotationMirror)andAnnotatedTypeMirror.removeAnnotation(javax.lang.model.element.AnnotationMirror), which already propagate to bounds for those three kinds.Also clears both bounds' annotations, for the same reason
removeAnnotation(AnnotationMirror)does: leaving a bound's annotations in place while clearing only this type variable's own primary annotation would let a bound keep a stale qualifier that a caller clearing this type is trying to discard, with no local signal that the two had gone out of sync.- Overrides:
clearAnnotationsin classAnnotatedTypeMirror
-
setDeclaration
public void setDeclaration(boolean declaration) Change whether thisAnnotatedTypeVariableis considered a use or a declaration (use this method with caution).- Parameters:
declaration- true if this type variable should be considered a declaration
-
asUse
- Overrides:
asUsein classAnnotatedTypeMirror
-
accept
Description copied from class:AnnotatedTypeMirrorApplies a visitor to this type.- Specified by:
acceptin classAnnotatedTypeMirror- Type Parameters:
R- the return type of the visitor's methodsP- the type of the additional parameter to the visitor's methods- Parameters:
v- the visitor operating on this typep- additional parameter to the visitor- Returns:
- a visitor-specified result
-
getUnderlyingType
Description copied from class:AnnotatedTypeMirrorReturns the underlying unannotated Java type, which this wraps.- Overrides:
getUnderlyingTypein classAnnotatedTypeMirror- Returns:
- the underlying type
-
setLowerBound
Set the lower bound of this variable type.Returns the lower bound of this type variable. While a type parameter cannot include an explicit lower bound declaration, capture conversion can produce a type variable with a non-trivial lower bound. Type variables otherwise have a lower bound of NullType.
This method is for framework usage only.
- Parameters:
type- the lower bound type
-
getLowerBoundField
Returns the lower bound field directly, bypassing any lazy initialization. This method is necessary to prevent infinite recursions in initialization. In general, prefer getLowerBound.- Returns:
- the lower bound field
-
getLowerBound
Returns the lower bound type of this type variable.- Returns:
- the lower bound type of this type variable
-
setUpperBound
Set the upper bound of this variable type.This method is for framework usage only.
- Parameters:
type- the upper bound type
-
getUpperBoundField
Returns the upper bound field directly, bypassing any lazy initialization. This method is necessary to prevent infinite recursions in initialization. In general, prefer getUpperBound.- Returns:
- the upper bound field
-
getUpperBound
Returns the upper bound of the type variable, possibly lazily initializing it. Attention: If the upper bound is lazily initialized, it contains only the annotations written on the declaration's bound, not the defaults! Callers of the method have to make sure that an AnnotatedTypeFactory first processed the bound.- Returns:
- the upper bound type of this type variable
-
getBounds
Returns the upper and lower bounds of this type variable, forcing their lazy initialization if necessary.- Returns:
- the bounds of this type variable
-
getBoundFields
Returns the upper and lower bound fields of this type variable directly, without forcing lazy initialization (the fields may be null).- Returns:
- the bound fields of this type variable
-
deepCopy
Description copied from class:AnnotatedTypeMirrorReturns a deep copy of this type. A deep copy implies that each component type is copied recursively and the returned type refers to those copies in its component locations.Note: deepCopy provides two important properties in the returned copy:
- Structure preservation -- The exact structure of the original AnnotatedTypeMirror is preserved in the copy including all component types.
- Annotation preservation -- All of the annotations from the original AnnotatedTypeMirror and its components have been copied to the new type.
- Specified by:
deepCopyin classAnnotatedTypeMirror- Returns:
- a deep copy
-
deepCopy
Description copied from class:AnnotatedTypeMirrorReturns a deep copy of this type with annotations.Each subclass implements this method with the subclass return type. The method body must always be a call to deepCopy(true).
- Specified by:
deepCopyin interfaceDeepCopyable<AnnotatedTypeMirror>- Specified by:
deepCopyin classAnnotatedTypeMirror- Returns:
- a deep copy of this type with annotations
- See Also:
-
shallowCopy
Description copied from class:AnnotatedTypeMirrorReturns a shallow copy of this type. A shallow copy implies that each component type in the output copy refers to the same object as the object being copied.- Specified by:
shallowCopyin classAnnotatedTypeMirror- Parameters:
copyAnnotations- true if copy should have annotations, i.e., fieldannotationsshould be copied- Returns:
- a shallow copy of this type
-
shallowCopy
Description copied from class:AnnotatedTypeMirrorReturns a shallow copy of this type with annotations.Each subclass implements this method with the subclass return type. The method body must always be a call to shallowCopy(true).
- Specified by:
shallowCopyin classAnnotatedTypeMirror- Returns:
- a shallow copy of this type with annotations
- See Also:
-
getErased
This method will traverse the upper bound of this type variable calling getErased until it finds the concrete upper bound. e.g.
A call to getErased will return the type List<E extends T>, T extends S, S extends List<String>>- Overrides:
getErasedin classAnnotatedTypeMirror- Returns:
- the erasure of the upper bound of this type
IMPORTANT NOTE: getErased should always return a FRESH object. This will occur for type variables if all other getErased methods are implemented appropriately. Therefore, to avoid extra copy calls, this method will not call deepCopy on getUpperBound
- See Also:
-