Class TUConstraint
- java.lang.Object
-
- org.checkerframework.framework.util.typeinference.constraint.TUConstraint
-
public abstract class TUConstraint extends java.lang.Object
Subclasses of TUConstraint represent constraints between a type parameter, whose type arguments are being inferred, and the types used to do that inference. These constraints are used by the TASolver to infer arguments.TU constraints come in the classic form of subtype, supertype, and equality constraints.
T <: U
-- implies T is a subtype of U, it is represented by TSubU
T >: U
-- implies T is a supertype of U, it is represented by TSuperU
T = U
-- implies T is equal to U, it is represented by TIsU
Note, it is important that the type parameter is represented by an AnnotatedTypeVariable because if a use of the type parameter has a primary annotation, then the two types represented in by a TUConstraint are NOT constrained in the hierarchy of that annotation. e.g.
The above method call would eventually be reduced to constraints:<T> void method(List<@NonNull T> t1, T t2) method(new ArrayList<@NonNull String>(), null);
[@NonNull String == @NonNull T, @Nullable null <: T]
In this example, if we did not ignore the first constraint then the type argument would be exactly @NonNull String and the second argument would be invalid. However, the correct inference would be @Nullable String and both arguments would be valid.
-
-
Field Summary
Fields Modifier and Type Field Description AnnotatedTypeMirror
relatedType
A type used to infer an argument for the typeVariable T.AnnotatedTypeMirror.AnnotatedTypeVariable
typeVariable
An AnnotatedTypeVariable representing a target type parameter for which we are inferring a type argument.boolean
uIsArg
Whether or not U is a type from an argument to the method.
-
Constructor Summary
Constructors Modifier Constructor Description protected
TUConstraint(AnnotatedTypeMirror.AnnotatedTypeVariable typeVariable, AnnotatedTypeMirror relatedType, boolean uIsArg)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(@Nullable java.lang.Object thatObject)
int
hashCode()
-
-
-
Field Detail
-
typeVariable
public final AnnotatedTypeMirror.AnnotatedTypeVariable typeVariable
An AnnotatedTypeVariable representing a target type parameter for which we are inferring a type argument. This is the T in the TUConstraints.
-
relatedType
public final AnnotatedTypeMirror relatedType
A type used to infer an argument for the typeVariable T. This would be the U in the TUConstraints.
-
uIsArg
public final boolean uIsArg
Whether or not U is a type from an argument to the method.
-
-
Constructor Detail
-
TUConstraint
protected TUConstraint(AnnotatedTypeMirror.AnnotatedTypeVariable typeVariable, AnnotatedTypeMirror relatedType, boolean uIsArg)
-
-
Method Detail
-
equals
public boolean equals(@Nullable java.lang.Object thatObject)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-