Class AbstractType
java.lang.Object
org.checkerframework.framework.util.typeinference8.types.AbstractType
- Direct Known Subclasses:
InferenceType
,ProperType
,UseOfVariable
As explained in section 18.1,
the JLS Chapter on type inference use the term "type" to "include type-like syntax that contains
inference variables". This class represents this types. Three subclasses of this class are:
ProperType
: types that do not contain inference variablesVariable
: inference variablesInferenceType
: type-like syntax that contain at least one inference variable
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Java8InferenceContext
The context object.protected final AnnotatedTypeFactory
TheAnnotatedTypeFactory
. -
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractType
(Java8InferenceContext context) Creates anAbstractType
. -
Method Summary
Modifier and TypeMethodDescriptionabstract AbstractType
Return a new type that is the same as this one except the variables ininstantiations
have been replaced by their instantiation.asSuper
(TypeMirror superType) IfsuperType
is 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) Return a new type that is the capture of this type.abstract AbstractType
create
(AnnotatedTypeMirror atm, TypeMirror type) Creates a type using the given types.boolean
abstract AnnotatedTypeMirror
Return the underlying Java type without inference variables.final AbstractType
Return the array component type fo this type or null if on does not exist.Return 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, then this method returns the return type of the function type of that functional interface.abstract Collection<Variable>
Return a collection of all inference variables referenced by this type.Return assuming type is an intersection type, this method returns the bounds in this type.abstract TypeMirror
Return the underlying Java type without inference variables.abstract AbstractType.Kind
getKind()
Returns the kind ofAbstractType
.Return 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.Return this type's type arguments or null if this type isn't a declared type.final TypeKind
Returns the TypeKind of the underlying Java type.Assuming the type is a declared type, this method returns the upper bounds of its type parameters.Return assuming this type is a type variable that has a lower bound, this method returns the lower bound of this type.Return assuming this type is a type variable, this method returns the upper bound of this type.Return if this type is a wildcard return its lower bound; otherwise, return null.Return if this type is a wildcard return its upper bound; otherwise, return null.int
hashCode()
boolean
Return true if this type contains inference variables, but is not an inference variable.boolean
Return true if the type is a wildcard with a lower bound.boolean
Return true if this type is a type variable with a lower bound.abstract boolean
isObject()
Return true if this type is java.lang.Object.boolean
Whether the proper type is a parameterized class or interface type, or an inner class type of a parameterized class or interface type (directly or indirectly)boolean
Return true if this type is a primitive array.boolean
isProper()
Return true if this type is a proper type.boolean
isRaw()
Return true if the type is a raw type.boolean
Return true if the type is an unbound wildcard.boolean
Return true if the type is a wildcard with an upper bound.boolean
Return true if this type is a use of an inference variable.boolean
Return true if this type is a parameterized type whose has at least one wildcard as a type argument.replaceTypeArgs
(List<AbstractType> args) Return a new type that is the same type as this one, but whose type arguments areargs
.
-
Field Details
-
context
The context object. -
typeFactory
TheAnnotatedTypeFactory
.
-
-
Constructor Details
-
AbstractType
Creates anAbstractType
.- Parameters:
context
- the context object
-
-
Method Details
-
getKind
Returns the kind ofAbstractType
.- Returns:
- the kind of
AbstractType
-
isProper
public boolean isProper()Return true if this type is a proper type.- Returns:
- true if this type is a proper type
-
isUseOfVariable
public boolean isUseOfVariable()Return 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()Return 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 mirrortype
- type mirror- Returns:
- the new type
-
getJavaType
Return the underlying Java type without inference variables.- Returns:
- the underlying Java type without inference variables
-
getAnnotatedType
Return the underlying Java type without inference variables.- Returns:
- the underlying Java type without inference variables
-
getInferenceVariables
Return a collection of all inference variables referenced by this type.- Returns:
- a collection of all inference variables referenced by this type
-
applyInstantiations
Return a new type that is the same as this one except the variables ininstantiations
have been replaced by their instantiation.- Returns:
- a new type that is the same as this one except the variables in
instantiations
have been replaced by their instantiation
-
isObject
public abstract boolean isObject()Return 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.)- Returns:
- the upper bounds of the type parameter of this type
-
capture
Return 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
IfsuperType
is 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
superType
or null if one doesn't exist
-
getFunctionTypeReturnType
If this type is a functional interface, then this method returns the return type of the function type of that functional interface. Otherwise, returns null.- Returns:
- the return type of the function type of this type or null if one doesn't exist
-
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.- Returns:
- the parameter types of the function type of this type or null if no function type exists
-
isRaw
public boolean isRaw()Return true if the type is a raw type.- Returns:
- true if the type is a raw type
-
replaceTypeArgs
Return 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()Whether the proper type is a parameterized class or interface type, or an inner class type of a parameterized class or interface type (directly or indirectly)- Returns:
- whether T is a parameterized type
-
getMostSpecificArrayType
Return 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()Return true if this type is a primitive array.- Returns:
- true if this type is a primitive array
-
getIntersectionBounds
Return 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
Return 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
Return 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()Return 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()Return true if this type is a parameterized type whose has at least one wildcard as a type argument.- Returns:
- true if this type is a parameterized type whose has at least one wildcard as a type argument
-
getTypeArguments
Return this type's type arguments or null if this type isn't a declared type.- Returns:
- this type's type arguments or null this type isn't a declared type
-
isUnboundWildcard
public boolean isUnboundWildcard()Return true if the type is an unbound wildcard.- Returns:
- true if the type is an unbound wildcard
-
isUpperBoundedWildcard
public boolean isUpperBoundedWildcard()Return 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()Return true if the type is a wildcard with a lower bound.- Returns:
- true if the type is a wildcard with a lower bound
-
getWildcardLowerBound
Return if this type is a wildcard return its lower bound; otherwise, return null.- Returns:
- if this type is a wildcard return its lower bound; otherwise, return null
-
getWildcardUpperBound
Return if this type is a wildcard return its upper bound; otherwise, return null.- Returns:
- if this type is a wildcard return its upper bound; otherwise, return null
-
getErased
Return 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
Return the array component type fo this type or null if on 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
-
equals
-
hashCode
public int hashCode()
-