|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object checkers.types.TypeHierarchy
public class TypeHierarchy
Class to test AnnotatedTypeMirror
subtype relationships.
The implementation uses the regular traditional Java subtyping rules,
assuming qual(A) := qualifier on A
and
|A| = type without qualifier
:
1. A <: B iff |A| <: |B| && qual(A) <: qual(B)
2. A[] <: B[] iff A <: B and qual(A[]) <: qual(B[])
3. A<A_1, ..., A_n> <: B<B_1, ..., B_n>
if A <: B && A_1 = B_1 && ... && A_n = B_n
Subclasses may need to override the methods as specified below, to override this behavior.
Please note that the array subtyping rules depends on a runtime check to guarantee the soundness of the type system. It is unsafe for static check purposes.
Constructor Summary | |
---|---|
TypeHierarchy(QualifierHierarchy qualifierHierarchy)
Constructs an instance of TypeHierarchy for the type system
whose qualifiers represented in qualifierHierarchy. |
Method Summary | |
---|---|
boolean |
isSubtype(AnnotatedTypeMirror rhs,
AnnotatedTypeMirror lhs)
Entry point for subtype checking: Checks whether rhs is a subtype of lhs |
protected boolean |
isSubtypeAsArrayComponent(AnnotatedTypeMirror rhs,
AnnotatedTypeMirror lhs)
Checks that rhs is a subtype of lhs, as an array component type. |
protected boolean |
isSubtypeAsTypeArgument(AnnotatedTypeMirror rhs,
AnnotatedTypeMirror lhs)
Checks that rhs is a subtype of lhs, as actual type arguments. |
protected boolean |
isSubtypeTypeArguments(AnnotatedTypeMirror.AnnotatedDeclaredType rhs,
AnnotatedTypeMirror.AnnotatedDeclaredType lhs)
Checks that rhs and lhs are subtypes with respect to type arguments only. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TypeHierarchy(QualifierHierarchy qualifierHierarchy)
TypeHierarchy
for the type system
whose qualifiers represented in qualifierHierarchy.
qualifierHierarchy
- Method Detail |
---|
public final boolean isSubtype(AnnotatedTypeMirror rhs, AnnotatedTypeMirror lhs)
protected boolean isSubtypeTypeArguments(AnnotatedTypeMirror.AnnotatedDeclaredType rhs, AnnotatedTypeMirror.AnnotatedDeclaredType lhs)
As an implementation detail, this method uses
isSubtypeAsTypeArgument(AnnotatedTypeMirror, AnnotatedTypeMirror)
to compare each type argument individually. Subclasses may override
either methods to allow type argument to change covariantly.
protected boolean isSubtypeAsTypeArgument(AnnotatedTypeMirror rhs, AnnotatedTypeMirror lhs)
protected boolean isSubtypeAsArrayComponent(AnnotatedTypeMirror rhs, AnnotatedTypeMirror lhs)
This property of arrays makes the code unsafe at run-time. Subclasses may override this method to enforce a stricter relationship.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |