Class AbstractType
- Direct Known Subclasses:
InferenceType,ProperType,UseOfVariable
ProperType: types that do not contain inference variablesVariable: inference variablesInferenceType: type-like syntax that contains at least one inference variable
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Java8InferenceContextThe context object.If thisAbstractTypeis a functional interface type, thenfunctionTypeis its function type.final booleanTrue if the annotations on this type should be ignored.protected final AnnotatedTypeFactoryTheAnnotatedTypeFactory. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractType(Java8InferenceContext context, boolean ignoreAnnotations) Creates anAbstractType. -
Method Summary
Modifier and TypeMethodDescriptionabstract AbstractTypeReturns a new type that is the same as this one except the variables ininstantiationshave been replaced by their instantiation.asSuper(TypeMirror superType) IfsuperTypeis a super type of this type, then this method returns the super type of this type that is the same class assuperType.capture(Java8InferenceContext context) Returns a new type that is the capture of this type.protected final ConstraintSetcheckAnnotationSubtype(ProperType superType) Checks whether the annotations ofthisare a subtype of those ofsuperType, assuming that their underlying Java types have already been found to be in the required relationship.final List<AbstractType> create(Collection<? extends AnnotatedTypeMirror> atms, boolean ignoreAnnotations) Creates types using the given types.abstract AbstractTypecreate(AnnotatedTypeMirror atm, boolean ignoreAnnotations) Creates a type using the given types.abstract booleanabstract AnnotatedTypeMirrorReturns the underlying annotated type.final @Nullable AbstractTypeReturns the array component type of this type or null if one does not exist.Returns this type's enclosing type, or null if this type is not an inner class type.Returns new type whose Java type is the erasure of this type.If this type is a functional interface, then this method returns the parameter types of the function type of that functional interface.If this type is a functional interface whose function type has a non-void return type, then this method returns that return type.abstract Collection<Variable> Returns a collection of all inference variables referenced by this type.Returns assuming type is an intersection type, this method returns the bounds in this type.abstract TypeMirrorReturns the underlying Java type without inference variables.abstract AbstractType.KindgetKind()Returns the kind ofAbstractType.Returns the most specific array type that is a super type of this type or null if one doesn't exist.abstract Set<AbstractQualifier> Returns the primary qualifiers on this type.Returns this type's type arguments or null if this type isn't a declared type.final TypeKindReturns the TypeKind of the underlying Java type.Assuming the type is a declared type, this method returns the upper bounds of its type parameters.Returns assuming this type is a type variable that has a lower bound, this method returns the lower bound of this type.Returns assuming this type is a type variable, this method returns the upper bound of this type.If this type is a wildcard, returns its lower bound; otherwise, returns null.If this type is a wildcard, returns its upper bound; otherwise, returns null.abstract inthashCode()protected final intReturns a hash code for the fields thatsameInferenceProblem(org.checkerframework.framework.util.typeinference8.types.AbstractType)compares.booleanReturns true if thisAbstractTypeis a functional interface type.booleanReturns true if this type contains inference variables, but is not an inference variable.booleanReturns true if the type is a wildcard with a lower bound.booleanReturns true if this type is a type variable with a lower bound.abstract booleanisObject()Returns true if this type is java.lang.Object.booleanReturns true if this type is a parameterized class or interface type, an inner class type of a parameterized class or interface type (directly or indirectly), or a raw type.booleanReturns true if this type is a primitive array.booleanisProper()Returns true if this type is a proper type.booleanisRaw()Returns true if the type is a raw type.booleanReturns true if the type is an unbound wildcard.booleanReturns true if the type is a wildcard with an upper bound.booleanReturns true if this type is a use of an inference variable.booleanReturns true if this type is a parameterized type that has at least one wildcard as a type argument.replaceTypeArgs(List<AbstractType> args) Returns a new type that is the same type as this one, but whose type arguments areargs.protected final booleanReturns true ifthatbelongs to the same inference problem as this type and treats annotations the same way as this type does.
-
Field Details
-
context
The context object. -
typeFactory
TheAnnotatedTypeFactory. -
ignoreAnnotations
public final boolean ignoreAnnotationsTrue if the annotations on this type should be ignored.This field applies to every qualifier hierarchy at once, even when it was set because of a primary annotation that appears in only some of the hierarchies. TODO: Make this per-hierarchy, so that the hierarchies without such a primary annotation are still compared.
-
functionType
If thisAbstractTypeis a functional interface type, thenfunctionTypeis its function type. Otherwise,functionTypeis null. Initialized bygetFunctionType().
-
-
Constructor Details
-
AbstractType
Creates anAbstractType.- Parameters:
context- the context objectignoreAnnotations- true if the annotations on this type should be ignored
-
-
Method Details
-
getKind
Returns the kind ofAbstractType.- Returns:
- the kind of
AbstractType
-
isProper
public boolean isProper()Returns true if this type is a proper type.- Returns:
- true if this type is a proper type
-
isUseOfVariable
public boolean isUseOfVariable()Returns true if this type is a use of an inference variable.- Returns:
- true if this type is a use of an inference variable
-
isInferenceType
public boolean isInferenceType()Returns true if this type contains inference variables, but is not an inference variable.- Returns:
- true if this type contains inference variables, but is not an inference variable
-
getTypeKind
Returns the TypeKind of the underlying Java type.- Returns:
- the TypeKind of the underlying Java type
-
create
Creates a type using the given types.- Parameters:
atm- annotated type mirrorignoreAnnotations- true if the annotations on this type should be ignored- Returns:
- the new type
-
create
public final List<AbstractType> create(Collection<? extends AnnotatedTypeMirror> atms, boolean ignoreAnnotations) Creates types using the given types.- Parameters:
atms- annotated type mirrorsignoreAnnotations- true if the annotations on this type should be ignored- Returns:
- the new types
-
getJavaType
Returns the underlying Java type without inference variables.- Returns:
- the underlying Java type without inference variables
-
getAnnotatedType
Returns the underlying annotated type.- Returns:
- the underlying annotated type
-
getInferenceVariables
Returns a collection of all inference variables referenced by this type.- Returns:
- a collection of all inference variables referenced by this type
-
applyInstantiations
Returns a new type that is the same as this one except the variables ininstantiationshave been replaced by their instantiation.- Returns:
- a new type that is the same as this one except the variables in
instantiationshave been replaced by their instantiation
-
isObject
public abstract boolean isObject()Returns true if this type is java.lang.Object.- Returns:
- true if this type is java.lang.Object
-
getTypeParameterBounds
Assuming the type is a declared type, this method returns the upper bounds of its type parameters. (A type parameter of a declared type, can't refer to any type being inferred, so they are proper types.)This implementation always returns a list. The return type is
@Nullableonly becauseUseOfVariable.getTypeParameterBounds()returns null.- Returns:
- the upper bounds of the type parameters of this type
-
capture
Returns a new type that is the capture of this type.- Parameters:
context- the context object- Returns:
- a new type that is the capture of this type
-
asSuper
IfsuperTypeis a super type of this type, then this method returns the super type of this type that is the same class assuperType. Otherwise, it returns null- Parameters:
superType- a type, need not be a super type of this type- Returns:
- super type of this type that is the same class as
superTypeor null if one doesn't exist
-
isFunctionalInterface
public boolean isFunctionalInterface()Returns true if thisAbstractTypeis a functional interface type.- Returns:
- true if this
AbstractTypeis a functional interface type
-
getFunctionTypeReturnType
If this type is a functional interface whose function type has a non-void return type, then this method returns that return type. Otherwise, returns null.Note that a null result does not distinguish between the two reasons for it: this type is not a functional interface, or the return type of its function type is void.
- Returns:
- the return type of the function type of this type, or null if this type is not a functional interface or its function type returns void
-
getFunctionTypeParameterTypes
If this type is a functional interface, then this method returns the parameter types of the function type of that functional interface. Otherwise, it returns null.Each call returns a new list, which the caller may modify.
- Returns:
- the parameter types of the function type of this type or null if no function type exists
-
isRaw
public boolean isRaw()Returns true if the type is a raw type.- Returns:
- true if the type is a raw type
-
replaceTypeArgs
Returns a new type that is the same type as this one, but whose type arguments areargs.- Parameters:
args- a list of type arguments- Returns:
- a new type that is the same type as this one, but whose type arguments are
args
-
isParameterizedType
public boolean isParameterizedType()Returns true if this type is a parameterized class or interface type, an inner class type of a parameterized class or interface type (directly or indirectly), or a raw type.- Returns:
- true if this type is a parameterized type or a raw type
-
getMostSpecificArrayType
Returns the most specific array type that is a super type of this type or null if one doesn't exist.- Returns:
- the most specific array type that is a super type of this type or null if one doesn't exist
-
isPrimitiveArray
public boolean isPrimitiveArray()Returns true if this type is a primitive array.- Returns:
- true if this type is a primitive array
-
getIntersectionBounds
Returns assuming type is an intersection type, this method returns the bounds in this type.- Returns:
- assuming type is an intersection type, this method returns the bounds in this type
-
getTypeVarUpperBound
Returns assuming this type is a type variable, this method returns the upper bound of this type.- Returns:
- assuming this type is a type variable, this method returns the upper bound of this type
-
getTypeVarLowerBound
Returns assuming this type is a type variable that has a lower bound, this method returns the lower bound of this type.- Returns:
- assuming this type is a type variable that has a lower bound, this method returns the lower bound of this type
-
isLowerBoundTypeVariable
public boolean isLowerBoundTypeVariable()Returns true if this type is a type variable with a lower bound.- Returns:
- true if this type is a type variable with a lower bound
-
isWildcardParameterizedType
public boolean isWildcardParameterizedType()Returns true if this type is a parameterized type that has at least one wildcard as a type argument.- Returns:
- true if this type is a parameterized type that has at least one wildcard as a type argument
-
getTypeArguments
Returns this type's type arguments or null if this type isn't a declared type. For an inner class type such asOuter<String>.Inner, the result does not include the type arguments of the enclosing type; usegetEnclosingType()to reach those.- Returns:
- this type's type arguments or null if this type isn't a declared type
-
getEnclosingType
Returns this type's enclosing type, or null if this type is not an inner class type. (A static nested class type has no enclosing type, in the sense of JLS 4.5.)The type arguments of an inner class type do not include those of its enclosing type, so a client that reasons about all the type arguments that a type mentions -- as JLS 18.2.3 and 18.2.4 do -- must recurse through this method as well as through
getTypeArguments().- Returns:
- this type's enclosing type, or null if this type is not an inner class type
-
isUnboundWildcard
public boolean isUnboundWildcard()Returns true if the type is an unbound wildcard.- Returns:
- true if the type is an unbound wildcard
-
isUpperBoundedWildcard
public boolean isUpperBoundedWildcard()Returns true if the type is a wildcard with an upper bound.- Returns:
- true if the type is a wildcard with an upper bound
-
isLowerBoundedWildcard
public boolean isLowerBoundedWildcard()Returns true if the type is a wildcard with a lower bound.- Returns:
- true if the type is a wildcard with a lower bound
-
getWildcardLowerBound
If this type is a wildcard, returns its lower bound; otherwise, returns null.- Returns:
- the lower bound of this wildcard type, or null if this type is not a wildcard
-
getWildcardUpperBound
If this type is a wildcard, returns its upper bound; otherwise, returns null. If the wildcard has no explicit upper bound, the returned type is the upper bound of the type variable to which the wildcard is bound; seeAnnotatedTypeMirror.AnnotatedWildcardType.getExtendsBound().- Returns:
- the upper bound of this wildcard type, or null if this type is not a wildcard
-
getErased
Returns new type whose Java type is the erasure of this type.- Returns:
- a new type whose Java type is the erasure of this type
-
getComponentType
Returns the array component type of this type or null if one does not exist.- Returns:
- the array component type of this type or null if one does not exist
-
getQualifiers
Returns the primary qualifiers on this type.- Returns:
- the primary qualifiers on this type
-
checkAnnotationSubtype
Checks whether the annotations ofthisare a subtype of those ofsuperType, assuming that their underlying Java types have already been found to be in the required relationship. If either type is marked as having annotations that should be ignored, then the annotations are not compared.- Parameters:
superType- the potential supertype- Returns:
ConstraintSet.TRUEif the annotations are ignored or if the annotations ofthisare a subtype of those ofsuperType; otherwiseConstraintSet.TRUE_ANNO_FAIL
-
equals
-
hashCode
public abstract int hashCode() -
sameInferenceProblem
Returns true ifthatbelongs to the same inference problem as this type and treats annotations the same way as this type does. This is a helper method forequals(java.lang.Object); it says nothing about the types themselves.- Parameters:
that- another abstract type- Returns:
- true if
thatbelongs to the same inference problem as this type and treats annotations the same way as this type does
-
inferenceProblemHashCode
protected final int inferenceProblemHashCode()Returns a hash code for the fields thatsameInferenceProblem(org.checkerframework.framework.util.typeinference8.types.AbstractType)compares. This is a helper method forhashCode().- Returns:
- a hash code for the fields that
sameInferenceProblem(org.checkerframework.framework.util.typeinference8.types.AbstractType)compares
-