Class SupertypesSolver
java.lang.Object
org.checkerframework.framework.util.typeinference.solver.SupertypesSolver
Infers type arguments by using the Least Upper Bound computation on the supertype relationships
in a constraint map.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic AnnotatedTypeMirror
groundMissingHierarchies
(Map.Entry<AnnotatedTypeMirror, AnnotationMirrorSet> typeToHierarchies, AnnotationMirrorMap<AnnotationMirror> lowerBoundAnnos) For each type in typeToHierarchies, if that type does not have a corresponding annotation for a given hierarchy replace it with the corresponding value in lowerBoundAnnos.static AnnotatedTypeMirror
leastUpperBound
(TypeVariable target, AnnotatedTypeFactory typeFactory, Map<AnnotatedTypeMirror, AnnotationMirrorSet> types) Successively calls least upper bound on the elements of types.protected static void
lubPrimaries
(AnnotationMirrorMap<AnnotationMirror> lubOfPrimaries, AnnotationMirrorMap<AnnotationMirrorSet> subtypeAnnos, AnnotationMirrorSet tops, QualifierHierarchy qualHierarchy) For each qualifier hierarchy in tops, take the lub of the annos in subtypeAnnos that correspond to that hierarchy place the lub in lubOfPrimaries.protected @Nullable InferredValue.InferredType
mergeLubAnnosWithEqualities
(TypeVariable target, AnnotationMirrorMap<AnnotationMirror> lubAnnos, ConstraintMap constraintMap, AnnotatedTypeFactory typeFactory) We previously found a type that is equal to target but not in all hierarchies.protected @Nullable InferredValue.InferredType
mergeLubTypeWithEqualities
(TypeVariable target, AnnotatedTypeMirror lub, ConstraintMap constraintMap, AnnotatedTypeFactory typeFactory) We previously found a type that is equal to target but not in all hierarchies.protected static void
propagatePreviousLubs
(TargetConstraints targetRecord, org.checkerframework.framework.util.typeinference.solver.SupertypesSolver.Lubs solution, Map<AnnotatedTypeMirror, AnnotationMirrorSet> subtypesOfTarget) If the target corresponding to targetRecord must be a supertype of another target for which we have already determined a lub, add that target's lub to this list.solveFromSupertypes
(Set<TypeVariable> remainingTargets, ConstraintMap constraintMap, AnnotatedTypeFactory typeFactory) Infers type arguments using supertype constraints.
-
Constructor Details
-
SupertypesSolver
public SupertypesSolver()
-
-
Method Details
-
solveFromSupertypes
public InferenceResult solveFromSupertypes(Set<TypeVariable> remainingTargets, ConstraintMap constraintMap, AnnotatedTypeFactory typeFactory) Infers type arguments using supertype constraints.- Parameters:
remainingTargets
- targets for which we still need to infer a valueconstraintMap
- the set of constraints for all targets- Returns:
- a mapping from target to inferred type. Note this class always infers concrete types and will not infer that the target is equivalent to another target.
-
mergeLubTypeWithEqualities
protected @Nullable InferredValue.InferredType mergeLubTypeWithEqualities(TypeVariable target, AnnotatedTypeMirror lub, ConstraintMap constraintMap, AnnotatedTypeFactory typeFactory) We previously found a type that is equal to target but not in all hierarchies. Use the primary annotations from the lub type to fill in the missing annotations in this type. Use that type as the inferred argument.If we failed to infer any annotation for a given hierarchy, either previously from equalities or from the lub, return null.
-
mergeLubAnnosWithEqualities
protected @Nullable InferredValue.InferredType mergeLubAnnosWithEqualities(TypeVariable target, AnnotationMirrorMap<AnnotationMirror> lubAnnos, ConstraintMap constraintMap, AnnotatedTypeFactory typeFactory) We previously found a type that is equal to target but not in all hierarchies. Use the primary annotations from the lub annos to fill in the missing annotations in this type. Use that type as the inferred argument.If we failed to infer any annotation for a given hierarchy, either previously from equalities or from the lub, return null.
-
propagatePreviousLubs
protected static void propagatePreviousLubs(TargetConstraints targetRecord, org.checkerframework.framework.util.typeinference.solver.SupertypesSolver.Lubs solution, Map<AnnotatedTypeMirror, AnnotationMirrorSet> subtypesOfTarget) If the target corresponding to targetRecord must be a supertype of another target for which we have already determined a lub, add that target's lub to this list. -
lubPrimaries
protected static void lubPrimaries(AnnotationMirrorMap<AnnotationMirror> lubOfPrimaries, AnnotationMirrorMap<AnnotationMirrorSet> subtypeAnnos, AnnotationMirrorSet tops, QualifierHierarchy qualHierarchy) For each qualifier hierarchy in tops, take the lub of the annos in subtypeAnnos that correspond to that hierarchy place the lub in lubOfPrimaries. -
groundMissingHierarchies
public static AnnotatedTypeMirror groundMissingHierarchies(Map.Entry<AnnotatedTypeMirror, AnnotationMirrorSet> typeToHierarchies, AnnotationMirrorMap<AnnotationMirror> lowerBoundAnnos) For each type in typeToHierarchies, if that type does not have a corresponding annotation for a given hierarchy replace it with the corresponding value in lowerBoundAnnos. -
leastUpperBound
public static AnnotatedTypeMirror leastUpperBound(TypeVariable target, AnnotatedTypeFactory typeFactory, Map<AnnotatedTypeMirror, AnnotationMirrorSet> types) Successively calls least upper bound on the elements of types. Unlike AnnotatedTypes.leastUpperBound, this method will box primitives if necessary
-