Class AnnotatedTypeMirror.AnnotatedWildcardType
- java.lang.Object
-
- org.checkerframework.framework.type.AnnotatedTypeMirror
-
- org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedWildcardType
-
- All Implemented Interfaces:
org.plumelib.util.DeepCopyable<AnnotatedTypeMirror>
- Enclosing class:
- AnnotatedTypeMirror
public static class AnnotatedTypeMirror.AnnotatedWildcardType extends AnnotatedTypeMirror
Represents a wildcard type argument. Examples include:? ? extends Number ? super T
A wildcard may have its upper bound explicitly set by an extends clause, its lower bound explicitly set by a super clause, or neither (but not both).
-
-
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
-
-
Field Summary
-
Fields inherited from class org.checkerframework.framework.type.AnnotatedTypeMirror
atypeFactory, EQUALITY_COMPARER, HASHCODE_VISITOR, primaryAnnotations, underlyingType
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <R,P>
Raccept(AnnotatedTypeVisitor<R,P> v, P p)
Applies a visitor to this type.void
addAnnotation(javax.lang.model.element.AnnotationMirror annotation)
Adds the canonical version ofannotation
as a primary annotation of this type and, in the case ofAnnotatedTypeMirror.AnnotatedTypeVariable
s,AnnotatedTypeMirror.AnnotatedWildcardType
s, andAnnotatedTypeMirror.AnnotatedIntersectionType
s, adds it to all bounds.AnnotatedTypeMirror.AnnotatedWildcardType
deepCopy()
Returns a deep copy of this type with annotations.AnnotatedTypeMirror.AnnotatedWildcardType
deepCopy(boolean copyAnnotations)
Returns a deep copy of this type.AnnotatedTypeMirror
getErased()
Returns the erasure type of this type, according to JLS specifications.AnnotatedTypeMirror
getExtendsBound()
Returns the upper bound of this wildcard.AnnotatedTypeMirror
getExtendsBoundField()
AnnotatedTypeMirror
getSuperBound()
Returns the lower bound of this wildcard.AnnotatedTypeMirror
getSuperBoundField()
javax.lang.model.type.TypeVariable
getTypeVariable()
Returns the type variable to which this wildcard is an argument.javax.lang.model.type.WildcardType
getUnderlyingType()
Returns the underlying unannotated Java type, which this wraps.boolean
isUninferredTypeArgument()
Returns whether or not this wildcard is a type argument for which inference failed to infer a type.boolean
removeAnnotation(javax.lang.model.element.AnnotationMirror a)
Removes a primary annotation from the type.void
setUninferredTypeArgument()
Set that this wildcard is from an uninferred type argument.AnnotatedTypeMirror.AnnotatedWildcardType
shallowCopy()
Returns a shallow copy of this type with annotations.AnnotatedTypeMirror.AnnotatedWildcardType
shallowCopy(boolean copyAnnotations)
Returns a shallow copy of this type.-
Methods inherited from class org.checkerframework.framework.type.AnnotatedTypeMirror
addAnnotation, addAnnotations, addMissingAnnotation, addMissingAnnotations, asUse, clearAnnotations, containsUninferredTypeArguments, createType, createTypeOfObject, createTypeOfRecord, directSupertypes, equals, getAnnotation, getAnnotation, getAnnotationInHierarchy, getAnnotations, getAnnotationsField, getEffectiveAnnotation, getEffectiveAnnotationInHierarchy, getEffectiveAnnotations, getExplicitAnnotations, getKind, getPrimitiveKind, getUnderlyingTypeHashCode, hasAnnotation, hasAnnotation, hasAnnotationInHierarchy, hasAnnotationRelaxed, hasEffectiveAnnotation, hasEffectiveAnnotation, hasEffectiveAnnotationRelaxed, hasExplicitAnnotation, hasExplicitAnnotation, hasExplicitAnnotationRelaxed, hashCode, isAnnotatedInHierarchy, isDeclaration, removeAnnotationByClass, removeAnnotationInHierarchy, removeAnnotations, removeNonTopAnnotationInHierarchy, replaceAnnotation, replaceAnnotations, toString, toString
-
-
-
-
Method Detail
-
addAnnotation
public void addAnnotation(javax.lang.model.element.AnnotationMirror annotation)
Description copied from class:AnnotatedTypeMirror
Adds the canonical version ofannotation
as a primary annotation of this type and, in the case ofAnnotatedTypeMirror.AnnotatedTypeVariable
s,AnnotatedTypeMirror.AnnotatedWildcardType
s, andAnnotatedTypeMirror.AnnotatedIntersectionType
s, adds it to all bounds. (The canonical version is found viaAnnotatedTypeFactory.canonicalAnnotation(javax.lang.model.element.AnnotationMirror)
.) If the canonical version ofannotation
is 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:
addAnnotation
in classAnnotatedTypeMirror
- Parameters:
annotation
- the annotation to add
-
removeAnnotation
public boolean removeAnnotation(javax.lang.model.element.AnnotationMirror a)
Description copied from class:AnnotatedTypeMirror
Removes a primary annotation from the type.- Overrides:
removeAnnotation
in classAnnotatedTypeMirror
- Parameters:
a
- the annotation to remove- Returns:
- true if the annotation was removed, false if the type's annotations were unchanged
-
getSuperBoundField
public AnnotatedTypeMirror getSuperBoundField()
-
getSuperBound
public AnnotatedTypeMirror getSuperBound()
Returns the lower bound of this wildcard. If no lower bound is explicitly declared, returns anAnnotatedTypeMirror.AnnotatedNullType
.- Returns:
- the lower bound of this wildcard, or an
AnnotatedTypeMirror.AnnotatedNullType
if none is explicitly declared
-
getExtendsBoundField
public AnnotatedTypeMirror getExtendsBoundField()
-
getExtendsBound
public AnnotatedTypeMirror getExtendsBound()
Returns the upper bound of this wildcard. If no upper bound is explicitly declared, returns the upper bound of the type variable to which the wildcard is bound.- Returns:
- the upper bound of this wildcard. If no upper bound is explicitly declared, returns the upper bound of the type variable to which the wildcard is bound.
-
getTypeVariable
public javax.lang.model.type.TypeVariable getTypeVariable()
Returns the type variable to which this wildcard is an argument. Used to initialize the upper bound of wildcards in raw types.- Returns:
- the type variable to which this wildcard is an argument
-
accept
public <R,P> R accept(AnnotatedTypeVisitor<R,P> v, P p)
Description copied from class:AnnotatedTypeMirror
Applies a visitor to this type.- Specified by:
accept
in 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
public javax.lang.model.type.WildcardType getUnderlyingType()
Description copied from class:AnnotatedTypeMirror
Returns the underlying unannotated Java type, which this wraps.- Overrides:
getUnderlyingType
in classAnnotatedTypeMirror
- Returns:
- the underlying type
-
deepCopy
public AnnotatedTypeMirror.AnnotatedWildcardType deepCopy(boolean copyAnnotations)
Description copied from class:AnnotatedTypeMirror
Returns 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:
deepCopy
in classAnnotatedTypeMirror
- Returns:
- a deep copy
-
deepCopy
public AnnotatedTypeMirror.AnnotatedWildcardType deepCopy()
Description copied from class:AnnotatedTypeMirror
Returns 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:
deepCopy
in interfaceorg.plumelib.util.DeepCopyable<AnnotatedTypeMirror>
- Specified by:
deepCopy
in classAnnotatedTypeMirror
- Returns:
- a deep copy of this type with annotations
- See Also:
AnnotatedTypeMirror.deepCopy(boolean)
-
shallowCopy
public AnnotatedTypeMirror.AnnotatedWildcardType shallowCopy(boolean copyAnnotations)
Description copied from class:AnnotatedTypeMirror
Returns 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:
shallowCopy
in classAnnotatedTypeMirror
- Parameters:
copyAnnotations
- whether copy should have annotations, i.e. whether fieldannotations
should be copied.
-
shallowCopy
public AnnotatedTypeMirror.AnnotatedWildcardType shallowCopy()
Description copied from class:AnnotatedTypeMirror
Returns 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:
shallowCopy
in classAnnotatedTypeMirror
- Returns:
- a shallow copy of this type with annotations
- See Also:
AnnotatedTypeMirror.shallowCopy(boolean)
-
getErased
public AnnotatedTypeMirror getErased()
Description copied from class:AnnotatedTypeMirror
Returns the erasure type of this type, according to JLS specifications.- Overrides:
getErased
in classAnnotatedTypeMirror
- Returns:
- the erasure of this AnnotatedTypeMirror, this is always a copy even if the erasure and the original type are equivalent
- See Also:
AnnotatedTypeMirror.AnnotatedTypeVariable.getErased()
-
setUninferredTypeArgument
public void setUninferredTypeArgument()
Set that this wildcard is from an uninferred type argument. This method should only be used within the framework. Once issues that depend on this hack, in particular Issue 979, are fixed, this must be removed.
-
isUninferredTypeArgument
public boolean isUninferredTypeArgument()
Returns whether or not this wildcard is a type argument for which inference failed to infer a type.- Returns:
- true if this wildcard is a type argument for which inference failed
-
-