java.lang.Object
org.checkerframework.framework.util.typeinference8.types.Variable
Direct Known Subclasses:
CaptureVariable

@Interned public class Variable extends Object
An inference variable. It corresponds to a type argument for a particular method invocation, new class tree or method reference that needs to be inferred.
  • Field Details

    • variableBounds

      protected final VariableBounds variableBounds
      Bounds of this variable.
    • id

      protected final int id
      Identification number. Used only to make debugging easier.
    • invocation

      protected final ExpressionTree invocation
      The expression for which this variable is being solved. Used to differentiate inference variables for two different invocations of the same method or constructor. This is set during inference.
    • typeVariableJava

      protected final TypeVariable typeVariableJava
      Type variable for which the instantiation of this variable is a type argument,
    • typeVariable

      protected final AnnotatedTypeMirror.AnnotatedTypeVariable typeVariable
      Type variable for which the instantiation of this variable is a type argument,
    • map

      protected final Theta map
      A mapping from type variable to inference variable.
    • context

      protected final Java8InferenceContext context
      The context.
  • Constructor Details

    • Variable

      protected Variable(AnnotatedTypeMirror.AnnotatedTypeVariable typeVariable, TypeVariable typeVariableJava, ExpressionTree invocation, Java8InferenceContext context, Theta map, int id)
      Creates a variable.
      Parameters:
      typeVariable - an annotated type variable
      typeVariableJava - a java type variable
      invocation - the invocation for which this variable is a type argument for
      context - the context
      map - a mapping from type variable to inference variable
      id - a unique number for this variable
  • Method Details

    • getBounds

      public VariableBounds getBounds()
      Return this variable's current bounds.
      Returns:
      this variable's current bounds
    • initialBounds

      public void initialBounds(Theta map)
      Adds the initial bounds to this variable. These are the bounds implied by the upper bounds of the type variable. See end of JLS 18.1.3.
      Parameters:
      map - used to determine if the bounds refer to another variable
    • getInvocation

      public ExpressionTree getInvocation()
      Returns the invocation tree.
      Returns:
      the invocation tree
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

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

      public ProperType getInstantiation()
      Returns the instantiation for this variable.
      Returns:
      the instantiation for this variable
    • save

      public void save()
      in case the first attempt at resolution fails.
    • restore

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

      public boolean isCaptureVariable()
      Returns whether this variable was created for a capture bound.
      Returns:
      whether this variable was created for a capture bound
    • getJavaType

      public TypeVariable getJavaType()
      The Java type variable.
      Returns:
      the Java type variable