Class ConstraintMapBuilder

java.lang.Object
org.checkerframework.framework.util.typeinference.solver.ConstraintMapBuilder

public class ConstraintMapBuilder extends Object
Converts a set of TUConstraints into a ConstraintMap.
  • Constructor Details

    • ConstraintMapBuilder

      public ConstraintMapBuilder()
  • Method Details

    • build

      public ConstraintMap build(Set<TypeVariable> targets, Set<TUConstraint> constraints, AnnotatedTypeFactory typeFactory)
      Let Ti be a the ith target being inferred Let ATV(i) be the annotated type variable that represents as use of Ti which may or may not have primary annotations. Let ATM be an annotated type mirror that may or may not be target Tx, or have a component target Tx Let Ai be the type argument we are trying to infer for Ti

      We have a set of constraints of the form: ATV(i) <?> ATM

      Where <?> is either a subtype (<:), supertype (:>), or equality relationship (=).

      Regardless of what <?> is, a constraint will only imply constraints on Ai in a given hierarchy if ATV(i) does NOT have a primary annotation in that hierarchy. That is:

      E.g. Let ATV(i) be @NonNull Ti, the constraints @NonNull Ti = @NonNull @Initialized String does not imply any primary annotation in the Nullness hierarchy for type argument Ai because the Annotated type mirror has a primary annotation in the NUllness hierarchy.

      However, it does imply that Ai has a primary annotation of @Initialized since ATV(i) has no primary annotation in the initialization hierarchy.

      Note, constraints come in 2 forms:

      • between a target and a concrete AnnotatedTypeMirror. E.g., As seen above (@NonNull Ti = @NonNull @Initialized String)
      • between two targets E.g., (@NonNull Ti = Tj)
    • addToPrimaryRelationship

      public void addToPrimaryRelationship(TypeVariable typeVariable, TUConstraint constraint, ConstraintMap result, AnnotationMirrorSet annotationMirrors, QualifierHierarchy qualHierarchy)
    • addToTypeRelationship

      public void addToTypeRelationship(TypeVariable target, AnnotatedTypeMirror type, ConstraintMap result, TUConstraint constraint, AnnotationMirrorSet hierarchies)