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.boolean
isSubtype
(AnnotatedTypeMirror subtype, AnnotatedTypeMirror supertype) Returns true ifsubtype
is a subtype of or convertible tosupertype
for all hierarchies present.boolean
isSubtypeShallowEffective
(Collection<? extends AnnotationMirror> subQualifiers, AnnotatedTypeMirror supertype) Tests whethersubQualifiers
are equal to or are sub-qualifiers of the effective annotations ofsupertype
, according to the type qualifier hierarchy.boolean
isSubtypeShallowEffective
(AnnotationMirror subQualifier, AnnotatedTypeMirror supertype) Tests whethersubQualifier
is equal to or sub-qualifier of the effective annotation ofsupertype
in the same hierarchy assubQualifier
according to the type qualifier hierarchy.boolean
isSubtypeShallowEffective
(AnnotatedTypeMirror subtype, Collection<? extends AnnotationMirror> superQualifiers) Tests whether the effective annotations ofsubtype
are equal to or are sub-qualifiers ofsuperQualifiers
, according to the type qualifier hierarchy.boolean
isSubtypeShallowEffective
(AnnotatedTypeMirror subtype, AnnotationMirror superQualifier) Tests whether the effective annotation ofsubtype
in the same hierarchy assuperQualifier
is equal to or sub-qualifier ofsuperQualifier
, according to the type qualifier hierarchy.boolean
isSubtypeShallowEffective
(AnnotatedTypeMirror subtype, AnnotatedTypeMirror supertype) Tests whether the effective annotations ofsubtype
are equal to or are sub-qualifiers of the effective annotations ofsupertype
, according to the type qualifier hierarchy.boolean
isSubtypeShallowEffective
(AnnotatedTypeMirror subtype, AnnotatedTypeMirror supertype, AnnotationMirror hierarchy) Tests whether the effective annotation in the same hierarchy ashierarchy
ofsubtype
are equal to or are sub-qualifiers of the effective annotation ofsupertype
in the same hierarchy ashierarchy
, according to the type qualifier hierarchy.
-
Method Details
-
isSubtype
Returns true ifsubtype
is a subtype of or convertible tosupertype
for all hierarchies present. If the underlying Java type ofsubtype
is 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
subtype
is a subtype ofsupertype
for all hierarchies present
- Boxing conversions: isSubtype calls
-
isSubtypeShallowEffective
Tests whether the effective annotations ofsubtype
are equal to or are sub-qualifiers of the effective annotations ofsupertype
, according to the type qualifier hierarchy.The underlying types of
subtype
andsupertype
are 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
subtype
are 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 ashierarchy
ofsubtype
are equal to or are sub-qualifiers of the effective annotation ofsupertype
in the same hierarchy ashierarchy
, according to the type qualifier hierarchy. Other annotations insubtype
andsupertype
are ignored.The underlying types of
subtype
andsupertype
are 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 comparesubtype
andsupertype
- Returns:
- true iff the effective annotation in the same hierarchy as
hierarchy
ofsubtype
are equal to or are sub-qualifiers of the effective annotation ofsupertype
in the same hierarchy ashierarchy
-
isSubtypeShallowEffective
boolean isSubtypeShallowEffective(AnnotatedTypeMirror subtype, Collection<? extends AnnotationMirror> superQualifiers) Tests whether the effective annotations ofsubtype
are equal to or are sub-qualifiers ofsuperQualifiers
, according to the type qualifier hierarchy. Other annotations insubtype
are ignored.The underlying type of
subtype
is 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
subtype
are equal to or are sub-qualifiers ofsuperQualifiers
-
isSubtypeShallowEffective
boolean isSubtypeShallowEffective(Collection<? extends AnnotationMirror> subQualifiers, AnnotatedTypeMirror supertype) Tests whethersubQualifiers
are equal to or are sub-qualifiers of the effective annotations ofsupertype
, according to the type qualifier hierarchy. Other annotations insupertype
are ignored.The underlying type of
supertype
is used by this method for special cases when qualifier subtyping depends on the Java basetype.- Parameters:
subQualifiers
- possible subQualifierssupertype
- possible supertype- Returns:
- true iff
subQualifiers
are equal to or are sub-qualifiers of the effective annotations ofsupertype
-
isSubtypeShallowEffective
Tests whether the effective annotation ofsubtype
in the same hierarchy assuperQualifier
is equal to or sub-qualifier ofsuperQualifier
, according to the type qualifier hierarchy. The underlying types ofsubtype
is only used by this method for special cases when qualifier subtyping depends on the Java basetype. Other annotations insubtype
are ignored.- Parameters:
subtype
- possible subtypesuperQualifier
- possible super qualifier- Returns:
- true iffhe effective annotation of
subtype
in the same hierarchy assuperQualifier
is equal to or sub-qualifier ofsuperQualifier
-
isSubtypeShallowEffective
Tests whethersubQualifier
is equal to or sub-qualifier of the effective annotation ofsupertype
in the same hierarchy assubQualifier
according to the type qualifier hierarchy. The underlying types ofsupertype
is only used by this method for special cases when qualifier subtyping depends on the Java basetype. Other annotations insupertype
are ignored.- Parameters:
subQualifier
- possible subQualifiersupertype
- possible supertype- Returns:
- true
subQualifier
is equal to or sub-qualifier of the effective annotation ofsupertype
in 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
-