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

public class ConstraintMap extends Object
ConstraintMap holds simplified versions of the TUConstraints for ALL type variable for which we are inferring an argument. The ConstraintMap is edited on the fly as the various solvers work (unlike the AF/TU Constraints which are immutable).

This really consists of these things:

  1. a Map(target => constraints for target)
  2. Methods to easily build up the constraints in the map
  3. A getter for the constraints of individual targets.
Note: This class, along with TargetConstraints, uses a lot of mutable state and few setters/getters be careful. This choice was made as it makes the resulting code more readable.
  • Constructor Details

  • Method Details

    • getConstraints

      public TargetConstraints getConstraints(TypeVariable target)
      Gets the equality, subtypes, and supertypes constraints for a particular target.
    • getTargets

      public Set<TypeVariable> getTargets()
      Returns the set of all targets passed to the constructor of this constraint map (a target will appear in this list whether or not it has any constraints added).
      Returns:
      the set of all targets passed to the constructor of this constraint map (a target will appear in this list whether or not it has any constraints added)
    • addTargetEquality

      public void addTargetEquality(TypeVariable target, TypeVariable equivalent, AnnotationMirrorSet hierarchies)
      Add a constraint indicating that the equivalent is equal to target in the given qualifier hierarchies.
    • addPrimaryEqualities

      public void addPrimaryEqualities(TypeVariable target, QualifierHierarchy qualHierarchy, AnnotationMirrorSet annos)
      Add a constraint indicating that target has primary annotations equal to the given annotations.
    • addTargetSupertype

      public void addTargetSupertype(TypeVariable target, TypeVariable subtype, AnnotationMirrorSet hierarchies)
      Add a constraint indicating that target is a supertype of subtype in the given qualifier hierarchies.
      Parameters:
      hierarchies - a set of TOP annotations
    • addTypeSupertype

      public void addTypeSupertype(TypeVariable target, AnnotatedTypeMirror subtype, AnnotationMirrorSet hierarchies)
      Add a constraint indicating that target is a supertype of subtype in the given qualifier hierarchies.
      Parameters:
      hierarchies - a set of TOP annotations
    • addPrimarySupertype

      public void addPrimarySupertype(TypeVariable target, QualifierHierarchy qualHierarchy, AnnotationMirrorSet annos)
      Add a constraint indicating that target's primary annotations are subtypes of the given annotations.
    • addTargetSubtype

      public void addTargetSubtype(TypeVariable target, TypeVariable supertype, AnnotationMirrorSet hierarchies)
      Add a constraint indicating that target is a subtype of supertype in the given qualifier hierarchies.
      Parameters:
      hierarchies - a set of TOP annotations
    • addTypeSubtype

      public void addTypeSubtype(TypeVariable target, AnnotatedTypeMirror supertype, AnnotationMirrorSet hierarchies)
      Add a constraint indicating that target is a subtype of supertype in the given qualifier hierarchies.
      Parameters:
      hierarchies - a set of TOP annotations
    • addPrimarySubtypes

      public void addPrimarySubtypes(TypeVariable target, QualifierHierarchy qualHierarchy, AnnotationMirrorSet annos)
      Add a constraint indicating that target's primary annotations are subtypes of the given annotations.
    • addTypeEqualities

      public void addTypeEqualities(TypeVariable target, AnnotatedTypeMirror type, AnnotationMirrorSet hierarchies)
      Add a constraint indicating that target is equal to type in the given hierarchies.
      Parameters:
      hierarchies - a set of TOP annotations