java.lang.Object
org.checkerframework.framework.util.typeinference8.types.Variable
org.checkerframework.framework.util.typeinference8.types.CaptureVariable

@Interned public class CaptureVariable extends Variable
Variables created as a part of a capture bound.
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Variable
    • getWildcardConstraints

      public @Nullable ConstraintSet getWildcardConstraints(AbstractType Ai, AbstractType Bi)
      Returns the constraints generated when incorporating a capture bound, or null if the incorporation implies the bound false. See JLS 18.3.2.
      Parameters:
      Ai - the captured type argument
      Bi - the bound of the type variable
      Returns:
      constraints generated when incorporating a capture bound, or null if the bound false is implied
    • equals

      public boolean equals(Object o)

      Two capture variables are equal only if they are the same object. Every capture bound introduces fresh capture variables (see JLS 18.3.2), and the mapping created by InferenceFactory.createThetaForCapture(com.sun.source.tree.ExpressionTree, org.checkerframework.framework.util.typeinference8.types.AbstractType) is not cached, so two capture bounds for the same invocation create distinct capture variables for the same type variable. Those variables stand for different types, so Variable.equals(java.lang.Object), which compares the type variable and the invocation, must not be used for them. Reference equality is also what the @Interned annotation on this class requires.

      Variable.hashCode() is still correct for capture variables: it may return the same value for two capture variables that are not equal, which is permitted.

      Overrides:
      equals in class Variable
    • setCapturedWildcard

      public void setCapturedWildcard(boolean capturedWildcard)
      Sets whether the type argument that this variable captures is a wildcard.
      Parameters:
      capturedWildcard - true if the captured type argument is a wildcard
    • isCaptureVariable

      public boolean isCaptureVariable()
      Description copied from class: Variable
      Returns true if this variable was created for a capture bound.
      Overrides:
      isCaptureVariable in class Variable
      Returns:
      true if this variable was created for a capture bound
    • isCapturedWildcard

      public boolean isCapturedWildcard()
      Description copied from class: Variable
      Returns true if this variable was created for a capture bound and the type argument it captures is a wildcard.
      Overrides:
      isCapturedWildcard in class Variable
      Returns:
      true if this variable was created for a captured wildcard