Class TypeConstraint
java.lang.Object
org.checkerframework.framework.util.typeinference8.constraint.TypeConstraint
- All Implemented Interfaces:
Constraint,ReductionResult
- Direct Known Subclasses:
CheckedExceptionConstraint,Expression,Typing
Constraints are between either an expression and a type, two types, or an expression and a thrown
type. Defined in JLS section
18.1.2
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.checkerframework.framework.util.typeinference8.constraint.Constraint
Constraint.KindNested classes/interfaces inherited from interface org.checkerframework.framework.util.typeinference8.constraint.ReductionResult
ReductionResult.ReductionResultPair -
Field Summary
FieldsModifier and TypeFieldDescriptionThe constraint whose reduction created this constraint or null if this constraint isn't from a reduction from another.A string that describes where this constraint is from.protected AbstractTypeT, the type on the right-hand side of the constraint; may contain inference variables.Fields inherited from interface org.checkerframework.framework.util.typeinference8.constraint.ReductionResult
UNCHECKED_CONVERSION -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTypeConstraint(String source, AbstractType T) Creates a type constraint.protectedTypeConstraint(Constraint parent, AbstractType T) Creates a type constraint. -
Method Summary
Modifier and TypeMethodDescriptionaddAllLazily(Set<Variable> inputs, Set<Variable> toAdd) Returns the union ofinputsandtoAddwithout modifyinginputs.voidApply the given instantiations to any type mentioned in this constraint -- meaning replace any mention of a variable ininstantiationswith its proper type.Returns a string that explains where this constraint came from.booleanReturns a set of all inference variables mentioned by this constraint.Implementation ofConstraint.getInputVariables()that is used both by expressions constraints and checked exception constraints https://docs.oracle.com/javase/specs/jls/se8/html/jls-18.html#jls-18.5.2-200"The output variables of [expression] constraints are all inference variables mentioned by the type on the right-hand side of the constraint, T, that are not input variables."getT()Returns T which is the type on the right-hand side of the constraint.inthashCode()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.checkerframework.framework.util.typeinference8.constraint.Constraint
getInputVariables, getKind, reduce
-
Field Details
-
T
T, the type on the right-hand side of the constraint; may contain inference variables. -
parent
The constraint whose reduction created this constraint or null if this constraint isn't from a reduction from another. If null, thensourceshould be nonnull. -
source
A string that describes where this constraint is from. If null, then the constraint came from reducingparent.
-
-
Constructor Details
-
TypeConstraint
Creates a type constraint.- Parameters:
source- a string describing where this constraint came fromT- the type of the right-hand side of the constraint
-
TypeConstraint
Creates a type constraint.- Parameters:
parent- the constraint whose reduction created this constraintT- the type of the right-hand side of the constraint
-
-
Method Details
-
constraintHistory
Returns a string that explains where this constraint came from.- Returns:
- a string that explains where this constraint came from
-
getT
Returns T which is the type on the right-hand side of the constraint.- Returns:
- t, that is the type on the right-hand side of the constraint
-
getInferenceVariables
Returns a set of all inference variables mentioned by this constraint.The mutability/freshness guarantees are the same as
AbstractType.getInferenceVariables().- Returns:
- a set of all inference variables mentioned by this constraint
-
getOutputVariables
"The output variables of [expression] constraints are all inference variables mentioned by the type on the right-hand side of the constraint, T, that are not input variables."As defined in JLS section 18.5.2.2
Callers that need to mutate the result should make a defensive copy first.
- Returns:
- output variables for this constraint
-
addAllLazily
Returns the union ofinputsandtoAddwithout modifyinginputs.This method avoids allocation when
toAddis empty.- Parameters:
inputs- the input settoAdd- the set to add- Returns:
inputsitself whentoAddis empty; otherwise a new mutable set containing all variables frominputsandtoAdd
-
getInputVariablesForExpression
Implementation ofConstraint.getInputVariables()that is used both by expressions constraints and checked exception constraints https://docs.oracle.com/javase/specs/jls/se8/html/jls-18.html#jls-18.5.2-200- Parameters:
tree- an expression treeT- the type of the right-hand side of the constraint- Returns:
- the input variables for this constraint
-
applyInstantiations
public void applyInstantiations()Apply the given instantiations to any type mentioned in this constraint -- meaning replace any mention of a variable ininstantiationswith its proper type. -
equals
-
hashCode
public int hashCode()
-