java.lang.Object
org.checkerframework.framework.util.typeinference8.constraint.ConstraintSet
All Implemented Interfaces:
ReductionResult

public class ConstraintSet extends Object implements ReductionResult
A set of constraints and the operations that can be performed on them.
  • Field Details

    • TRUE

      public static final @InternedDistinct ConstraintSet TRUE
      The result given when a constraint set reduces to true.
    • TRUE_ANNO_FAIL

      public static final @InternedDistinct ConstraintSet TRUE_ANNO_FAIL
      The Java types are correct, but the qualifiers are not in the correct relationship. Return this rather than throwing an exception so that type arguments with the correct Java type are still inferred.
    • FALSE

      public static final @InternedDistinct ReductionResult FALSE
      The result given when a constraint set reduces to false.
  • Constructor Details

    • ConstraintSet

      public ConstraintSet(Constraint... constraints)
      Creates a constraint set with constraints.
      Parameters:
      constraints - constraints to add to the newly created set
  • Method Details

    • add

      public void add(Constraint c)
      Adds c to this set, if c isn't already in the list.
      Parameters:
      c - a constraint to add to this set
    • addAll

      public void addAll(ConstraintSet constraintSet)
      Adds all constraints in constraintSet to this constraint set.
      Parameters:
      constraintSet - a set of constraints to add to this set
    • addAll

      public void addAll(Collection<? extends Constraint> constraintSet)
      Adds all constraints in constraintSet to this constraint set.
      Parameters:
      constraintSet - a collection of constraints to add to this set
    • isEmpty

      public boolean isEmpty()
      Return whether or not this constraint set is empty.
      Returns:
      whether or not this constraint set is empty
    • pop

      public Constraint pop()
      Removes and returns the first constraint that was added to this set.
      Returns:
      first constraint that was added to this set
    • push

      public void push(Constraint constraint)
      Adds the constraint to the beginning of this set.
      Parameters:
      constraint - a constraint
    • pushAll

      public void pushAll(ConstraintSet constraints)
      Adds the constraints to the beginning of this set and maintains the order of the constraints.
      Parameters:
      constraints - constraints
    • remove

      public void remove(ConstraintSet subset)
      Remove all constraints in subset from this constraint set.
      Parameters:
      subset - the set of constraints to remove from this set
    • getClosedSubset

      public static ConstraintSet getClosedSubset(ConstraintSet c, Dependencies dependencies)
      Returns a subset of c; for each constraint in the subset, no input variable can influence an output variable of another constraint in C. If that subset is empty, returns a set containing a single constraint that participates in a constraint cycle. (See JLS 18.5.2.2)
      Parameters:
      c - a constraint set
      dependencies - an object describing the dependencies of inference variables
      Returns:
      s a subset of constraints in c whose inputs do not affect c's outputs, or a singleton constraint from a constraint cycle
    • getAllInferenceVariables

      public Set<Variable> getAllInferenceVariables()
      Return all variables mentioned by any constraint in this set.
      Returns:
      all variables mentioned by any constraint in this set
    • getAllInputVariables

      public Set<Variable> getAllInputVariables()
      Return all input variables for all constraints in this set.
      Returns:
      all input variables for all constraints in this set
    • applyInstantiations

      public void applyInstantiations()
      Applies the instantiations to all the constraints in this set.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • reduce

      public BoundSet reduce(Java8InferenceContext context)
      Reduces all the constraints in this set. (See JLS 18.2)
      Parameters:
      context - the context
      Returns:
      the bound set produced by reducing this constraint set
    • reduceAdditionalArgOnce

      public BoundSet reduceAdditionalArgOnce(Java8InferenceContext context)
      Reduces all the constraints in this set. (See JLS 18.2) If an AdditionalArgument is found it is reduced one step and then this method returns.
      Parameters:
      context - the context
      Returns:
      the bound set produced by reducing this constraint set
    • reduceOneStep

      public BoundSet reduceOneStep(Java8InferenceContext context)
      Reduce one constraint in this set.
      Parameters:
      context - the context
      Returns:
      the result of reducing one constraint in this set