public class DefaultTypeHierarchy extends AbstractAtmComboVisitor<Boolean,Void> implements TypeHierarchy
Subtyping rules of the JLS can be found in section 4.10, "Subtyping".
Note: The visit methods of this class must be public but it is intended to be used through a TypeHierarchy interface reference which will only allow isSubtype to be called. Clients should not call the visit methods.
Modifier and Type | Field and Description |
---|---|
protected BaseTypeChecker |
checker |
protected AnnotationMirror |
currentTop
The top annotation of the hierarchy currently being checked.
|
protected StructuralEqualityComparer |
equalityComparer |
protected boolean |
ignoreRawTypes |
protected boolean |
invariantArrayComponents |
protected QualifierHierarchy |
qualifierHierarchy |
protected StructuralEqualityVisitHistory |
typeargVisitHistory
Stores the result of isSubtype for type arguments.
|
protected SubtypeVisitHistory |
visitHistory
Stores the result of isSubtype, if that result is true.
|
Constructor and Description |
---|
DefaultTypeHierarchy(BaseTypeChecker checker,
QualifierHierarchy qualifierHierarchy,
boolean ignoreRawTypes,
boolean invariantArrayComponents)
Creates a DefaultTypeHierarchy.
|
defaultAction, visit, visitArray_Executable, visitArray_None, visitArray_Primitive, visitArray_Typevar, visitArray_Union, visitDeclared_Executable, visitDeclared_None, visitExecutable_Array, visitExecutable_Declared, visitExecutable_Executable, visitExecutable_Intersection, visitExecutable_None, visitExecutable_Null, visitExecutable_Primitive, visitExecutable_Typevar, visitExecutable_Union, visitExecutable_Wildcard, visitIntersection_Array, visitIntersection_Executable, visitIntersection_None, visitIntersection_Union, visitNone_Array, visitNone_Declared, visitNone_Executable, visitNone_Intersection, visitNone_None, visitNone_Null, visitNone_Primitive, visitNone_Union, visitNone_Wildcard, visitNull_Executable, visitNull_None, visitPrimitive_Array, visitPrimitive_Executable, visitPrimitive_None, visitPrimitive_Null, visitPrimitive_Union, visitTypevar_Array, visitTypevar_Executable, visitTypevar_None, visitTypevar_Union, visitUnion_Array, visitUnion_Executable, visitUnion_None, visitUnion_Null, visitUnion_Primitive, visitUnion_Typevar, visitWildcard_Executable, visitWildcard_None, visitWildcard_Null, visitWildcard_Union
protected final BaseTypeChecker checker
protected final QualifierHierarchy qualifierHierarchy
protected final StructuralEqualityComparer equalityComparer
protected final boolean ignoreRawTypes
protected final boolean invariantArrayComponents
protected AnnotationMirror currentTop
protected final SubtypeVisitHistory visitHistory
protected final StructuralEqualityVisitHistory typeargVisitHistory
public DefaultTypeHierarchy(BaseTypeChecker checker, QualifierHierarchy qualifierHierarchy, boolean ignoreRawTypes, boolean invariantArrayComponents)
protected StructuralEqualityComparer createEqualityComparer()
public boolean isSubtype(AnnotatedTypeMirror subtype, AnnotatedTypeMirror supertype)
This implementation iterates over all top annotations and invokes isSubtype(AnnotatedTypeMirror, AnnotatedTypeMirror, AnnotationMirror)
. Most type systems
should not override this method, but instead override isSubtype(AnnotatedTypeMirror,
AnnotatedTypeMirror, AnnotationMirror)
or some of the visitXXX
methods.
isSubtype
in interface TypeHierarchy
subtype
- expected subtypesupertype
- expected supertypeprotected boolean isSubtype(AnnotatedTypeMirror subtype, AnnotatedTypeMirror supertype, AnnotationMirror top)
subtype <: supertype
, but only for the hierarchy of which top
is the top.subtype
- expected subtypesupertype
- expected supertypetop
- the top of the hierarchy for which we want to make a comparisonsubtype
is a subtype of, or equal to, supertype
in
the qualifier hierarchy whose top is top
protected String defaultErrorMessage(AnnotatedTypeMirror subtype, AnnotatedTypeMirror supertype, Void p)
defaultErrorMessage
in class AbstractAtmComboVisitor<Boolean,Void>
subtype
- the first AnnotatedTypeMirror parameter to the visit method calledsupertype
- the second AnnotatedTypeMirror parameter to the visit method calledp
- subtype specific parameter passed to every visit methodprotected boolean isPrimarySubtype(AnnotatedTypeMirror subtype, AnnotatedTypeMirror supertype)
subtype
and supertype
. Neither type can be
missing annotations.protected boolean isPrimarySubtype(AnnotatedTypeMirror subtype, AnnotatedTypeMirror supertype, boolean annosCanBeEmtpy)
subtype
and supertype
.annosCanBeEmtpy
- indicates that annotations may be missing from the typemirrorprotected boolean isAnnoSubtype(@Nullable AnnotationMirror subtypeAnno, @Nullable AnnotationMirror supertypeAnno, boolean annosCanBeEmtpy)
subtype
and supertype
.subtypeAnno
- annotation that may be a subtypesupertypeAnno
- annotation that may be a supertypeannosCanBeEmtpy
- indicates that annotations may be missing from the typemirrorprotected boolean isBottom(AnnotatedTypeMirror subtype)
subtype
- type to test against bottomprotected boolean isSubtypeCaching(AnnotatedTypeMirror subtype, AnnotatedTypeMirror supertype)
isSubtype(AnnotatedTypeMirror, AnnotatedTypeMirror)
, but uses a cache to
prevent infinite recursion on recursive types.subtype
- a type that may be a subtypesupertype
- a type that may be a supertypeprotected boolean areAllSubtypes(Iterable<? extends AnnotatedTypeMirror> subtypes, AnnotatedTypeMirror supertype)
subtypes
a subtype of supertype
?
The underlying type mirrors of subtypes
must be subtypes of the underlying type
mirror of supertype
.
protected boolean areEqualInHierarchy(AnnotatedTypeMirror type1, AnnotatedTypeMirror type2)
protected boolean isContainedBy(AnnotatedTypeMirror inside, AnnotatedTypeMirror outside, boolean canBeCovariant)
inside
- a type argument of the "subtype"outside
- a type argument of the "supertype"canBeCovariant
- whether or not type arguments are allowed to be covariantinside <: outside
public Boolean visitArray_Array(AnnotatedTypeMirror.AnnotatedArrayType subtype, AnnotatedTypeMirror.AnnotatedArrayType supertype, Void p)
visitArray_Array
in interface AtmComboVisitor<Boolean,Void>
visitArray_Array
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitArray_Declared(AnnotatedTypeMirror.AnnotatedArrayType subtype, AnnotatedTypeMirror.AnnotatedDeclaredType supertype, Void p)
visitArray_Declared
in interface AtmComboVisitor<Boolean,Void>
visitArray_Declared
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitArray_Null(AnnotatedTypeMirror.AnnotatedArrayType subtype, AnnotatedTypeMirror.AnnotatedNullType supertype, Void p)
visitArray_Null
in interface AtmComboVisitor<Boolean,Void>
visitArray_Null
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitArray_Intersection(AnnotatedTypeMirror.AnnotatedArrayType subtype, AnnotatedTypeMirror.AnnotatedIntersectionType supertype, Void p)
visitArray_Intersection
in interface AtmComboVisitor<Boolean,Void>
visitArray_Intersection
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitArray_Wildcard(AnnotatedTypeMirror.AnnotatedArrayType subtype, AnnotatedTypeMirror.AnnotatedWildcardType supertype, Void p)
visitArray_Wildcard
in interface AtmComboVisitor<Boolean,Void>
visitArray_Wildcard
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitDeclared_Array(AnnotatedTypeMirror.AnnotatedDeclaredType subtype, AnnotatedTypeMirror.AnnotatedArrayType supertype, Void p)
visitDeclared_Array
in interface AtmComboVisitor<Boolean,Void>
visitDeclared_Array
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitDeclared_Declared(AnnotatedTypeMirror.AnnotatedDeclaredType subtype, AnnotatedTypeMirror.AnnotatedDeclaredType supertype, Void p)
visitDeclared_Declared
in interface AtmComboVisitor<Boolean,Void>
visitDeclared_Declared
in class AbstractAtmComboVisitor<Boolean,Void>
protected boolean visitTypeArgs(AnnotatedTypeMirror.AnnotatedDeclaredType subtype, AnnotatedTypeMirror.AnnotatedDeclaredType supertype, boolean subtypeRaw, boolean supertypeRaw)
public Boolean visitDeclared_Intersection(AnnotatedTypeMirror.AnnotatedDeclaredType subtype, AnnotatedTypeMirror.AnnotatedIntersectionType supertype, Void p)
visitDeclared_Intersection
in interface AtmComboVisitor<Boolean,Void>
visitDeclared_Intersection
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitDeclared_Null(AnnotatedTypeMirror.AnnotatedDeclaredType subtype, AnnotatedTypeMirror.AnnotatedNullType supertype, Void p)
visitDeclared_Null
in interface AtmComboVisitor<Boolean,Void>
visitDeclared_Null
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitDeclared_Primitive(AnnotatedTypeMirror.AnnotatedDeclaredType subtype, AnnotatedTypeMirror.AnnotatedPrimitiveType supertype, Void p)
visitDeclared_Primitive
in interface AtmComboVisitor<Boolean,Void>
visitDeclared_Primitive
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitDeclared_Typevar(AnnotatedTypeMirror.AnnotatedDeclaredType subtype, AnnotatedTypeMirror.AnnotatedTypeVariable supertype, Void p)
visitDeclared_Typevar
in interface AtmComboVisitor<Boolean,Void>
visitDeclared_Typevar
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitDeclared_Union(AnnotatedTypeMirror.AnnotatedDeclaredType subtype, AnnotatedTypeMirror.AnnotatedUnionType supertype, Void p)
visitDeclared_Union
in interface AtmComboVisitor<Boolean,Void>
visitDeclared_Union
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitDeclared_Wildcard(AnnotatedTypeMirror.AnnotatedDeclaredType subtype, AnnotatedTypeMirror.AnnotatedWildcardType supertype, Void p)
visitDeclared_Wildcard
in interface AtmComboVisitor<Boolean,Void>
visitDeclared_Wildcard
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitIntersection_Declared(AnnotatedTypeMirror.AnnotatedIntersectionType subtype, AnnotatedTypeMirror.AnnotatedDeclaredType supertype, Void p)
visitIntersection_Declared
in interface AtmComboVisitor<Boolean,Void>
visitIntersection_Declared
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitIntersection_Primitive(AnnotatedTypeMirror.AnnotatedIntersectionType subtype, AnnotatedTypeMirror.AnnotatedPrimitiveType supertype, Void p)
visitIntersection_Primitive
in interface AtmComboVisitor<Boolean,Void>
visitIntersection_Primitive
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitIntersection_Intersection(AnnotatedTypeMirror.AnnotatedIntersectionType subtype, AnnotatedTypeMirror.AnnotatedIntersectionType supertype, Void p)
visitIntersection_Intersection
in interface AtmComboVisitor<Boolean,Void>
visitIntersection_Intersection
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitIntersection_Null(AnnotatedTypeMirror.AnnotatedIntersectionType subtype, AnnotatedTypeMirror.AnnotatedNullType supertype, Void p)
visitIntersection_Null
in interface AtmComboVisitor<Boolean,Void>
visitIntersection_Null
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitIntersection_Typevar(AnnotatedTypeMirror.AnnotatedIntersectionType subtype, AnnotatedTypeMirror.AnnotatedTypeVariable supertype, Void p)
visitIntersection_Typevar
in interface AtmComboVisitor<Boolean,Void>
visitIntersection_Typevar
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitIntersection_Wildcard(AnnotatedTypeMirror.AnnotatedIntersectionType subtype, AnnotatedTypeMirror.AnnotatedWildcardType supertype, Void p)
visitIntersection_Wildcard
in interface AtmComboVisitor<Boolean,Void>
visitIntersection_Wildcard
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitNull_Array(AnnotatedTypeMirror.AnnotatedNullType subtype, AnnotatedTypeMirror.AnnotatedArrayType supertype, Void p)
visitNull_Array
in interface AtmComboVisitor<Boolean,Void>
visitNull_Array
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitNull_Declared(AnnotatedTypeMirror.AnnotatedNullType subtype, AnnotatedTypeMirror.AnnotatedDeclaredType supertype, Void p)
visitNull_Declared
in interface AtmComboVisitor<Boolean,Void>
visitNull_Declared
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitNull_Typevar(AnnotatedTypeMirror.AnnotatedNullType subtype, AnnotatedTypeMirror.AnnotatedTypeVariable supertype, Void p)
visitNull_Typevar
in interface AtmComboVisitor<Boolean,Void>
visitNull_Typevar
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitNull_Wildcard(AnnotatedTypeMirror.AnnotatedNullType subtype, AnnotatedTypeMirror.AnnotatedWildcardType supertype, Void p)
visitNull_Wildcard
in interface AtmComboVisitor<Boolean,Void>
visitNull_Wildcard
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitNull_Null(AnnotatedTypeMirror.AnnotatedNullType subtype, AnnotatedTypeMirror.AnnotatedNullType supertype, Void p)
visitNull_Null
in interface AtmComboVisitor<Boolean,Void>
visitNull_Null
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitNull_Union(AnnotatedTypeMirror.AnnotatedNullType subtype, AnnotatedTypeMirror.AnnotatedUnionType supertype, Void p)
visitNull_Union
in interface AtmComboVisitor<Boolean,Void>
visitNull_Union
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitNull_Intersection(AnnotatedTypeMirror.AnnotatedNullType subtype, AnnotatedTypeMirror.AnnotatedIntersectionType supertype, Void p)
visitNull_Intersection
in interface AtmComboVisitor<Boolean,Void>
visitNull_Intersection
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitNull_Primitive(AnnotatedTypeMirror.AnnotatedNullType subtype, AnnotatedTypeMirror.AnnotatedPrimitiveType supertype, Void p)
visitNull_Primitive
in interface AtmComboVisitor<Boolean,Void>
visitNull_Primitive
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitPrimitive_Declared(AnnotatedTypeMirror.AnnotatedPrimitiveType subtype, AnnotatedTypeMirror.AnnotatedDeclaredType supertype, Void p)
visitPrimitive_Declared
in interface AtmComboVisitor<Boolean,Void>
visitPrimitive_Declared
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitPrimitive_Primitive(AnnotatedTypeMirror.AnnotatedPrimitiveType subtype, AnnotatedTypeMirror.AnnotatedPrimitiveType supertype, Void p)
visitPrimitive_Primitive
in interface AtmComboVisitor<Boolean,Void>
visitPrimitive_Primitive
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitPrimitive_Intersection(AnnotatedTypeMirror.AnnotatedPrimitiveType subtype, AnnotatedTypeMirror.AnnotatedIntersectionType supertype, Void p)
visitPrimitive_Intersection
in interface AtmComboVisitor<Boolean,Void>
visitPrimitive_Intersection
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitPrimitive_Typevar(AnnotatedTypeMirror.AnnotatedPrimitiveType subtype, AnnotatedTypeMirror.AnnotatedTypeVariable supertype, Void p)
visitPrimitive_Typevar
in interface AtmComboVisitor<Boolean,Void>
visitPrimitive_Typevar
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitPrimitive_Wildcard(AnnotatedTypeMirror.AnnotatedPrimitiveType subtype, AnnotatedTypeMirror.AnnotatedWildcardType supertype, Void p)
visitPrimitive_Wildcard
in interface AtmComboVisitor<Boolean,Void>
visitPrimitive_Wildcard
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitUnion_Declared(AnnotatedTypeMirror.AnnotatedUnionType subtype, AnnotatedTypeMirror.AnnotatedDeclaredType supertype, Void p)
visitUnion_Declared
in interface AtmComboVisitor<Boolean,Void>
visitUnion_Declared
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitUnion_Intersection(AnnotatedTypeMirror.AnnotatedUnionType subtype, AnnotatedTypeMirror.AnnotatedIntersectionType supertype, Void p)
visitUnion_Intersection
in interface AtmComboVisitor<Boolean,Void>
visitUnion_Intersection
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitUnion_Union(AnnotatedTypeMirror.AnnotatedUnionType subtype, AnnotatedTypeMirror.AnnotatedUnionType supertype, Void p)
visitUnion_Union
in interface AtmComboVisitor<Boolean,Void>
visitUnion_Union
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitUnion_Wildcard(AnnotatedTypeMirror.AnnotatedUnionType subtype, AnnotatedTypeMirror.AnnotatedWildcardType supertype, Void p)
visitUnion_Wildcard
in interface AtmComboVisitor<Boolean,Void>
visitUnion_Wildcard
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitTypevar_Declared(AnnotatedTypeMirror.AnnotatedTypeVariable subtype, AnnotatedTypeMirror.AnnotatedDeclaredType supertype, Void p)
visitTypevar_Declared
in interface AtmComboVisitor<Boolean,Void>
visitTypevar_Declared
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitTypevar_Intersection(AnnotatedTypeMirror.AnnotatedTypeVariable subtype, AnnotatedTypeMirror.AnnotatedIntersectionType supertype, Void p)
visitTypevar_Intersection
in interface AtmComboVisitor<Boolean,Void>
visitTypevar_Intersection
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitTypevar_Primitive(AnnotatedTypeMirror.AnnotatedTypeVariable subtype, AnnotatedTypeMirror.AnnotatedPrimitiveType supertype, Void p)
visitTypevar_Primitive
in interface AtmComboVisitor<Boolean,Void>
visitTypevar_Primitive
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitTypevar_Typevar(AnnotatedTypeMirror.AnnotatedTypeVariable subtype, AnnotatedTypeMirror.AnnotatedTypeVariable supertype, Void p)
visitTypevar_Typevar
in interface AtmComboVisitor<Boolean,Void>
visitTypevar_Typevar
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitTypevar_Null(AnnotatedTypeMirror.AnnotatedTypeVariable subtype, AnnotatedTypeMirror.AnnotatedNullType supertype, Void p)
visitTypevar_Null
in interface AtmComboVisitor<Boolean,Void>
visitTypevar_Null
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitTypevar_Wildcard(AnnotatedTypeMirror.AnnotatedTypeVariable subtype, AnnotatedTypeMirror.AnnotatedWildcardType supertype, Void p)
visitTypevar_Wildcard
in interface AtmComboVisitor<Boolean,Void>
visitTypevar_Wildcard
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitWildcard_Array(AnnotatedTypeMirror.AnnotatedWildcardType subtype, AnnotatedTypeMirror.AnnotatedArrayType supertype, Void p)
visitWildcard_Array
in interface AtmComboVisitor<Boolean,Void>
visitWildcard_Array
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitWildcard_Declared(AnnotatedTypeMirror.AnnotatedWildcardType subtype, AnnotatedTypeMirror.AnnotatedDeclaredType supertype, Void p)
visitWildcard_Declared
in interface AtmComboVisitor<Boolean,Void>
visitWildcard_Declared
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitWildcard_Intersection(AnnotatedTypeMirror.AnnotatedWildcardType subtype, AnnotatedTypeMirror.AnnotatedIntersectionType supertype, Void p)
visitWildcard_Intersection
in interface AtmComboVisitor<Boolean,Void>
visitWildcard_Intersection
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitWildcard_Primitive(AnnotatedTypeMirror.AnnotatedWildcardType subtype, AnnotatedTypeMirror.AnnotatedPrimitiveType supertype, Void p)
visitWildcard_Primitive
in interface AtmComboVisitor<Boolean,Void>
visitWildcard_Primitive
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitWildcard_Typevar(AnnotatedTypeMirror.AnnotatedWildcardType subtype, AnnotatedTypeMirror.AnnotatedTypeVariable supertype, Void p)
visitWildcard_Typevar
in interface AtmComboVisitor<Boolean,Void>
visitWildcard_Typevar
in class AbstractAtmComboVisitor<Boolean,Void>
public Boolean visitWildcard_Wildcard(AnnotatedTypeMirror.AnnotatedWildcardType subtype, AnnotatedTypeMirror.AnnotatedWildcardType supertype, Void p)
visitWildcard_Wildcard
in interface AtmComboVisitor<Boolean,Void>
visitWildcard_Wildcard
in class AbstractAtmComboVisitor<Boolean,Void>
protected boolean visitIntersectionSupertype(AnnotatedTypeMirror subtype, AnnotatedTypeMirror.AnnotatedIntersectionType supertype)
protected boolean visitTypevarSupertype(AnnotatedTypeMirror subtype, AnnotatedTypeMirror.AnnotatedTypeVariable supertype)
subtype
- a type that might be a subtypesupertype
- a type that might be a supertypesubtype
is a subtype of supertype
protected boolean visitTypevarSubtype(AnnotatedTypeMirror.AnnotatedTypeVariable subtype, AnnotatedTypeMirror supertype)
protected boolean visitUnionSubtype(AnnotatedTypeMirror.AnnotatedUnionType subtype, AnnotatedTypeMirror supertype)
protected boolean visitWildcardSupertype(AnnotatedTypeMirror subtype, AnnotatedTypeMirror.AnnotatedWildcardType supertype)
protected boolean visitWildcardSubtype(AnnotatedTypeMirror.AnnotatedWildcardType subtype, AnnotatedTypeMirror supertype)