Interface TypeHierarchy
- All Known Implementing Classes:
DefaultTypeHierarchy
QualifierHierarchy.-
Method Summary
Modifier and TypeMethodDescriptionReturns a list of the indices of the type arguments that are covariant.booleanisSubtype(AnnotatedTypeMirror subtype, AnnotatedTypeMirror supertype) Returns true ifsubtypeis a subtype of or convertible tosupertypefor all hierarchies present.booleanisSubtypeShallowEffective(Collection<? extends AnnotationMirror> subQualifiers, AnnotatedTypeMirror supertype) Tests whethersubQualifiersare equal to or are sub-qualifiers of the effective annotations ofsupertype, according to the type qualifier hierarchy.booleanisSubtypeShallowEffective(AnnotationMirror subQualifier, AnnotatedTypeMirror supertype) Tests whethersubQualifieris equal to or sub-qualifier of the effective annotation ofsupertypein the same hierarchy assubQualifieraccording to the type qualifier hierarchy.booleanisSubtypeShallowEffective(AnnotatedTypeMirror subtype, Collection<? extends AnnotationMirror> superQualifiers) Tests whether the effective annotations ofsubtypeare equal to or are sub-qualifiers ofsuperQualifiers, according to the type qualifier hierarchy.booleanisSubtypeShallowEffective(AnnotatedTypeMirror subtype, AnnotationMirror superQualifier) Tests whether the effective annotation ofsubtypein the same hierarchy assuperQualifieris equal to or sub-qualifier ofsuperQualifier, according to the type qualifier hierarchy.booleanisSubtypeShallowEffective(AnnotatedTypeMirror subtype, AnnotatedTypeMirror supertype) Tests whether the effective annotations ofsubtypeare equal to or are sub-qualifiers of the effective annotations ofsupertype, according to the type qualifier hierarchy.booleanisSubtypeShallowEffective(AnnotatedTypeMirror subtype, AnnotatedTypeMirror supertype, AnnotationMirror hierarchy) Tests whether the effective annotation in the same hierarchy ashierarchyofsubtypeare equal to or are sub-qualifiers of the effective annotation ofsupertypein the same hierarchy ashierarchy, according to the type qualifier hierarchy.
-
Method Details
-
isSubtype
Returns true ifsubtypeis a subtype of or convertible tosupertypefor all hierarchies present. If the underlying Java type ofsubtypeis not a subtype of or convertible to the underlying Java type ofsupertype, then the behavior of this method is undefined.Ideally, types that require conversions would be converted before isSubtype is called, but instead, isSubtype performs some of these conversions.
JLS 5.1 specifies 13 categories of conversions.
3 categories are converted in isSubtype:
- Boxing conversions: isSubtype calls
AnnotatedTypeFactory.getBoxedType(org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedPrimitiveType) - Unboxing conversions: isSubtype calls
AnnotatedTypeFactory.getUnboxedType(org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType) - String conversions: Any type to String. isSubtype calls
AnnotatedTypes.asSuper(org.checkerframework.framework.type.AnnotatedTypeFactory, org.checkerframework.framework.type.AnnotatedTypeMirror, T)which callsAnnotatedTypeFactory.getStringType(AnnotatedTypeMirror)
- Unchecked conversions: Generic type to raw type. Raw types are instantiated with bounds in AnnotatedTypeFactory#fromTypeTree before is subtype is called
- Capture conversions: Wildcards are captured in
AnnotatedTypeFactory.applyCaptureConversion(AnnotatedTypeMirror)
- Identity conversions: type to same type
- Widening primitive conversions: primitive to primitive (no loss of information, byte to short for example)
- Narrowing primitive conversions: primitive to primitive (possibly loss of information, short to byte for example)
- Widening and Narrowing Primitive Conversion: byte to char
- Widening reference conversions: Upcast
- Narrowing reference conversions: Downcast
- Value set conversions: floating-point value from one value set to another without changing its type.
- Parameters:
subtype- possible subtypesupertype- possible supertype- Returns:
- true if
subtypeis a subtype ofsupertypefor all hierarchies present
- Boxing conversions: isSubtype calls
-
isSubtypeShallowEffective
Tests whether the effective annotations ofsubtypeare equal to or are sub-qualifiers of the effective annotations ofsupertype, according to the type qualifier hierarchy.The underlying types of
subtypeandsupertypeare not necessarily in a Java subtyping relationship with one another and are only used by this method for special cases when qualifier subtyping depends on the Java basetype.- Parameters:
subtype- possible subtypesupertype- possible supertype- Returns:
- true iff the effective annotations of
subtypeare equal to or are sub-qualifiers of the effective annotations ofsupertype
-
isSubtypeShallowEffective
boolean isSubtypeShallowEffective(AnnotatedTypeMirror subtype, AnnotatedTypeMirror supertype, AnnotationMirror hierarchy) Tests whether the effective annotation in the same hierarchy ashierarchyofsubtypeare equal to or are sub-qualifiers of the effective annotation ofsupertypein the same hierarchy ashierarchy, according to the type qualifier hierarchy. Other annotations insubtypeandsupertypeare ignored.The underlying types of
subtypeandsupertypeare not necessarily in a Java subtyping relationship with one another and are only used by this method for special cases when qualifier subtyping depends on the Java basetype.- Parameters:
subtype- possible subtypesupertype- possible supertypehierarchy- an annotation whose hierarchy is used to comparesubtypeandsupertype- Returns:
- true iff the effective annotation in the same hierarchy as
hierarchyofsubtypeare equal to or are sub-qualifiers of the effective annotation ofsupertypein the same hierarchy ashierarchy
-
isSubtypeShallowEffective
boolean isSubtypeShallowEffective(AnnotatedTypeMirror subtype, Collection<? extends AnnotationMirror> superQualifiers) Tests whether the effective annotations ofsubtypeare equal to or are sub-qualifiers ofsuperQualifiers, according to the type qualifier hierarchy. Other annotations insubtypeare ignored.The underlying type of
subtypeis only used by this method for special cases when qualifier subtyping depends on the Java basetype.- Parameters:
subtype- possible subtypesuperQualifiers- possible superQualifiers- Returns:
- true iff the effective annotations of
subtypeare equal to or are sub-qualifiers ofsuperQualifiers
-
isSubtypeShallowEffective
boolean isSubtypeShallowEffective(Collection<? extends AnnotationMirror> subQualifiers, AnnotatedTypeMirror supertype) Tests whethersubQualifiersare equal to or are sub-qualifiers of the effective annotations ofsupertype, according to the type qualifier hierarchy. Other annotations insupertypeare ignored.The underlying type of
supertypeis used by this method for special cases when qualifier subtyping depends on the Java basetype.- Parameters:
subQualifiers- possible subQualifierssupertype- possible supertype- Returns:
- true iff
subQualifiersare equal to or are sub-qualifiers of the effective annotations ofsupertype
-
isSubtypeShallowEffective
Tests whether the effective annotation ofsubtypein the same hierarchy assuperQualifieris equal to or sub-qualifier ofsuperQualifier, according to the type qualifier hierarchy. The underlying types ofsubtypeis only used by this method for special cases when qualifier subtyping depends on the Java basetype. Other annotations insubtypeare ignored.- Parameters:
subtype- possible subtypesuperQualifier- possible super qualifier- Returns:
- true iffhe effective annotation of
subtypein the same hierarchy assuperQualifieris equal to or sub-qualifier ofsuperQualifier
-
isSubtypeShallowEffective
Tests whethersubQualifieris equal to or sub-qualifier of the effective annotation ofsupertypein the same hierarchy assubQualifieraccording to the type qualifier hierarchy. The underlying types ofsupertypeis only used by this method for special cases when qualifier subtyping depends on the Java basetype. Other annotations insupertypeare ignored.- Parameters:
subQualifier- possible subQualifiersupertype- possible supertype- Returns:
- true
subQualifieris equal to or sub-qualifier of the effective annotation ofsupertypein the same hierarchy assubQualifier
-
getCovariantArgIndexes
Returns a list of the indices of the type arguments that are covariant.- Parameters:
type- a type- Returns:
- a list of the indices of the type arguments that are covariant
-