java.lang.Object
org.checkerframework.framework.util.typeinference8.bound.BoundSet
All Implemented Interfaces:
ReductionResult

public class BoundSet extends Object implements ReductionResult
Manages a set of bounds. Bounds are stored in the variable to which they apply, except for capture bounds which are stored in this class.
  • Field Details

    • MAX_INCORPORATION_STEPS

      public static final int MAX_INCORPORATION_STEPS
      Max number of incorporation loops. Use same constant as Infer.MAX_INCORPORATION_STEPS
      See Also:
    • annoInferenceFailed

      public boolean annoInferenceFailed
      If true, then type argument inference failed because an annotated type could not be inferred.
    • errorMsg

      public String errorMsg
      The error message to report to users.
  • Constructor Details

    • BoundSet

      public BoundSet(Java8InferenceContext context)
      Creates a bound set.
      Parameters:
      context - the context
    • BoundSet

      public BoundSet(BoundSet toCopy)
      Copy constructor.
      Parameters:
      toCopy - bound set to copy
  • Method Details

    • saveBounds

      public void saveBounds()
      Save the current state of the variables so they can be restored if the first attempt at resolution fails.
    • restore

      public void restore()
      Restore the bounds to the last saved state. This method is called if the first attempt at resolution fails.
    • initialBounds

      public static BoundSet initialBounds(Theta theta, Java8InferenceContext context)
      Creates a new bound set for the variables in theta. (The initial bounds for the variables were added to the variables when theta was created.)
      Parameters:
      theta - a Map from type variable to inference variable
      context - inference context
      Returns:
      initial bounds
    • merge

      public boolean merge(BoundSet newSet)
      Merges newSet into this bound set.
      Parameters:
      newSet - bound set to merge
      Returns:
      whether the merge changed this bound set
    • addFalse

      public void addFalse()
      Adds the false bound to this bound set.
    • containsFalse

      public boolean containsFalse()
      Return whether this bound set contains false.
      Returns:
      whether this bound set contains false
    • isUncheckedConversion

      public boolean isUncheckedConversion()
      Return whether unchecked conversion was necessary to reduce and incorporate this bound set
      Returns:
      whether unchecked conversion was necessary to reduce and incorporate this bound set
    • setUncheckedConversion

      public void setUncheckedConversion(boolean uncheckedConversion)
      Sets whether unchecked conversion was necessary to reduce and incorporate this bound set.
      Parameters:
      uncheckedConversion - whether unchecked conversion was necessary to reduce and incorporate this bound set
    • addCapture

      public void addCapture(CaptureBound capture)
      Adds capture to this bound set.
      Parameters:
      capture - a capture bound
    • containsCapture

      public boolean containsCapture(Collection<Variable> as)
      Does the bound set contain a bound of the form G<..., ai, ...> = capture(G<...>) for any variable in as?
      Parameters:
      as - a collection of varialbes
      Returns:
      whether the bound set contain a bound of the form G<..., ai, ...> = capture(G<...>) for any variable in as
    • getInstantiationsInAlphas

      public List<Variable> getInstantiationsInAlphas(Collection<Variable> alphas)
      Returns a list of variables in alphas that are instantiated.
      Parameters:
      alphas - a list of variables
      Returns:
      a list of variables in alphas that are instantiated
    • getInstantiatedVariables

      public List<Variable> getInstantiatedVariables()
      Returns a list of all variables in this bound set that are instantiated.
      Returns:
      a list of all variables in this bound set that are instantiated
    • resolve

      public List<Variable> resolve()
      Resolve all inference variables mentioned in any bound.
      Returns:
      a list of resolved variables in this bounds set
    • getDependencies

      public Dependencies getDependencies()
      Returns the dependencies between variables.
      Returns:
      the dependencies between variables
    • getDependencies

      public Dependencies getDependencies(Collection<Variable> additionalVars)
      Adds the additionalVars to this bound set and returns the dependencies between all variables in this bound set.
      Parameters:
      additionalVars - variables to add to this bound set
      Returns:
      the dependencies between all variables in this bound set
    • incorporateToFixedPoint

      public void incorporateToFixedPoint(BoundSet newBounds)
      Incorporates newBounds into this bounds set.

      Incorporation creates new constraints that are then reduced to a bound set which is further incorporated into this bound set. Incorporation terminates when the bounds set has reached a fixed point. JLS 18 .1 defines this fixed point and further explains incorporation.

      Parameters:
      newBounds - bounds to incorporate
    • removeCaptures

      public void removeCaptures(Set<Variable> as)
      Remove any capture bound that mentions any variable in as.
      Parameters:
      as - a set of variables
    • toString

      public String toString()
      Overrides:
      toString in class Object