public class DefaultTypeHierarchy extends AbstractAtmComboVisitor<Boolean,Void> implements TypeHierarchy
Subtyping rules of the JLS can be found in section 4.10, "Subtyping": https://docs.oracle.com/javase/specs/jls/se10/html/jls-4.html#jls-4.10
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. It does not make sense to call the visit methods on their own.
Modifier and Type | Field and Description |
---|---|
protected BaseTypeChecker |
checker |
protected AnnotationMirror |
currentTop |
protected StructuralEqualityComparer |
equalityComparer |
protected boolean |
ignoreRawTypes |
protected boolean |
invariantArrayComponents |
protected QualifierHierarchy |
qualifierHierarchy |
protected SubtypeVisitHistory |
typeargVisitHistory |
protected SubtypeVisitHistory |
visitHistory |
Constructor and Description |
---|
DefaultTypeHierarchy(BaseTypeChecker checker,
QualifierHierarchy qualifierHierarchy,
boolean ignoreRawTypes,
boolean invariantArrayComponents) |
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, visitIntersection_Wildcard, 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 SubtypeVisitHistory typeargVisitHistory
public DefaultTypeHierarchy(BaseTypeChecker checker, QualifierHierarchy qualifierHierarchy, boolean ignoreRawTypes, boolean invariantArrayComponents)
public StructuralEqualityComparer createEqualityComparer()
public boolean isSubtype(AnnotatedTypeMirror subtype, AnnotatedTypeMirror supertype)
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)
top
is the top.subtype
- expected subtypesupertype
- expected supertypetop
- the hierarchy for which we want to make a comparisonsubtype
is a subtype of supertype
in the qualifier
hierarchy whose top is top
protected String defaultErrorMessage(AnnotatedTypeMirror subtype, AnnotatedTypeMirror supertype, Void p)
AbstractAtmComboVisitor
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)
protected boolean isPrimarySubtype(AnnotatedTypeMirror subtype, AnnotatedTypeMirror supertype, boolean annosCanBeEmtpy)
annosCanBeEmtpy
- indicates that annotations may be missing from the typemirrorprotected boolean isAnnoSubtype(AnnotationMirror subtypeAnno, AnnotationMirror supertypeAnno, boolean annosCanBeEmtpy)
subtypeAnno
- annotation we expect to be a subtypesupertypeAnno
- annotation we expect to be a supertype of subtypeannosCanBeEmtpy
- indicates that annotations may be missing from the typemirrorprotected boolean isBottom(AnnotatedTypeMirror subtype)
subtype
- type to isValid against bottomprotected boolean checkAndSubtype(AnnotatedTypeMirror subtype, AnnotatedTypeMirror supertype)
protected boolean isSubtypeOfAll(AnnotatedTypeMirror subtype, Iterable<? extends AnnotatedTypeMirror> supertypes)
protected boolean areAllSubtypes(Iterable<? extends AnnotatedTypeMirror> subtypes, AnnotatedTypeMirror supertype)
protected boolean areEqualInHierarchy(AnnotatedTypeMirror type1, AnnotatedTypeMirror type2)
protected boolean isContainedBy(AnnotatedTypeMirror inside, AnnotatedTypeMirror outside, boolean canBeCovariant)
inside
- the "subtype" type argumentoutside
- the "supertype" type argumentcanBeCovariant
- whether or not type arguments are allowed to be covariantpublic 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>
public 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 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)
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)
public static <T extends AnnotatedTypeMirror> T castedAsSuper(AnnotatedTypeMirror subtype, T supertype)
T
- the type of supertype and return typesubtype
- subtype to be transformed to supertypesupertype
- supertype that subtype is transformed to