java.lang.Object
org.checkerframework.framework.util.typeinference8.types.Dependencies

public class Dependencies extends Object
A data structure to hold the dependencies between variables. Dependencies are defined in JLS section 18.4 and impact the order in which variables are resolved.
  • Constructor Details

    • Dependencies

      public Dependencies()
      Creates Dependencies.
  • Method Details

    • putOrAdd

      public void putOrAdd(Variable key, Variable value)
      Add value as a dependency of key.
      Parameters:
      key - a key to add
      value - a value to add
    • putOrAddAll

      public void putOrAddAll(Variable key, Collection<? extends Variable> values)
      Add values as dependencies of key.
      Parameters:
      key - a key to add
      values - values to add
    • calculateTransitiveDependencies

      public void calculateTransitiveDependencies()
      Calculate and add transitive dependencies.

      JLS 18.4 "An inference variable alpha depends on the resolution of an inference variable beta if there exists an inference variable gamma such that alpha depends on the resolution of gamma and gamma depends on the resolution of beta."

    • get

      public Set<Variable> get(Variable alpha)
      Returns the set of dependencies of alpha, always including alpha itself, because JLS 18.4 says that an inference variable depends on the resolution of itself.

      If no dependency of alpha has been added to this object, the result is {alpha}. That case arises only for a variable that is absent from the bound set that created this object, because BoundSet.getDependencies records every variable of the bound set as a dependency of itself. For such a variable, {alpha} is a lower bound on its true dependencies: any dependency arising from its bounds is unknown to this object, so a caller may treat alpha as resolvable earlier or more independently than JLS 18.4 permits. Computing more than {alpha} here is not possible, because the transitive closure that BoundSet.getDependencies computes needs the whole bound set. Resolution.getSmallestDependencySet and ConstraintSet.getClosedSubset both query variables that the bound set does not necessarily contain, and letting such a variable depend on only itself lets inference proceed rather than crashing.

      The result is a new, mutable set; the caller may modify it.

      Parameters:
      alpha - a variable
      Returns:
      the set of dependencies of alpha
    • get

      public Set<Variable> get(List<Variable> variables)
      Returns the set of dependencies for all variables in variables. Every variable in variables is in the result; a variable to which no dependency has been added contributes only itself. See get(Variable).

      The result is a new, mutable set; the caller may modify it.

      Parameters:
      variables - list of variables
      Returns:
      the set of dependencies for all variables in variables