Class EqualitiesSolver
java.lang.Object
org.checkerframework.framework.util.typeinference.solver.EqualitiesSolver
EqualitiesSolver infers type arguments for targets using the equality constraints in
ConstraintMap. When a type is inferred, it rewrites the remaining equality/supertype constraints
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfindEqualTarget
(TargetConstraints.Equalities equalities, AnnotationMirrorSet tops) Attempt to find a target which is equal to this target.mergeConstraints
(TypeVariable target, TargetConstraints.Equalities equalities, InferenceResult solution, ConstraintMap constraintMap, AnnotatedTypeFactory typeFactory) solveEqualities
(Set<TypeVariable> targets, ConstraintMap constraintMap, AnnotatedTypeFactory typeFactory) For each target, if there is one or more equality constraints involving concrete types that lets us infer a primary annotation in all qualifier hierarchies then infer a concrete type argument.boolean
updateTargetsWithPartiallyInferredType
(TargetConstraints.Equalities equalities, ConstraintMap constraintMap, AnnotatedTypeFactory typeFactory)
-
Constructor Details
-
EqualitiesSolver
public EqualitiesSolver()
-
-
Method Details
-
solveEqualities
public InferenceResult solveEqualities(Set<TypeVariable> targets, ConstraintMap constraintMap, AnnotatedTypeFactory typeFactory) For each target, if there is one or more equality constraints involving concrete types that lets us infer a primary annotation in all qualifier hierarchies then infer a concrete type argument. else if there is one or more equality constraints involving other targets that lets us infer a primary annotation in all qualifier hierarchies then infer that type argument is the other type argumentif we have inferred either a concrete type or another target as type argument rewrite all of the constraints for the current target to instead use the inferred type/target
We do this iteratively until NO new inferred type argument is found
- Parameters:
targets
- the list of type parameters for which we are inferring type argumentsconstraintMap
- the set of constraints over the set of targets- Returns:
- a Map from target to (inferred type or target)
-
mergeConstraints
public InferredValue mergeConstraints(TypeVariable target, TargetConstraints.Equalities equalities, InferenceResult solution, ConstraintMap constraintMap, AnnotatedTypeFactory typeFactory) -
updateTargetsWithPartiallyInferredType
public boolean updateTargetsWithPartiallyInferredType(TargetConstraints.Equalities equalities, ConstraintMap constraintMap, AnnotatedTypeFactory typeFactory) -
findEqualTarget
public @Nullable InferredValue.InferredTarget findEqualTarget(TargetConstraints.Equalities equalities, AnnotationMirrorSet tops) Attempt to find a target which is equal to this target.- Returns:
- a target equal to this target in all hierarchies, or null
-