Class Variable
java.lang.Object
org.checkerframework.framework.util.typeinference8.types.Variable
- Direct Known Subclasses:
CaptureVariable
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 Summary
Modifier and TypeFieldDescriptionprotected final Java8InferenceContext
The context.protected final int
Identification number.protected final ExpressionTree
The expression for which this variable is being solved.protected final Theta
A mapping from type variable to inference variable.protected final AnnotatedTypeMirror.AnnotatedTypeVariable
Type variable for which the instantiation of this variable is a type argument,protected final TypeVariable
Type variable for which the instantiation of this variable is a type argument,protected final VariableBounds
Bounds of this variable. -
Constructor Summary
ModifierConstructorDescriptionprotected
Variable
(AnnotatedTypeMirror.AnnotatedTypeVariable typeVariable, TypeVariable typeVariableJava, ExpressionTree invocation, Java8InferenceContext context, Theta map, int id) Creates a variable. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Return this variable's current bounds.Returns the instantiation for this variable.Returns the invocation tree.The Java type variable.int
hashCode()
void
initialBounds
(Theta map) Adds the initial bounds to this variable.boolean
Returns whether this variable was created for a capture bound.void
restore()
Restore the bounds to the state previously saved.void
save()
in case the first attempt at resolution fails.toString()
-
Field Details
-
variableBounds
Bounds of this variable. -
id
protected final int idIdentification number. Used only to make debugging easier. -
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
Type variable for which the instantiation of this variable is a type argument, -
typeVariable
Type variable for which the instantiation of this variable is a type argument, -
map
A mapping from type variable to inference variable. -
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 variabletypeVariableJava
- a java type variableinvocation
- the invocation for which this variable is a type argument forcontext
- the contextmap
- a mapping from type variable to inference variableid
- a unique number for this variable
-
-
Method Details
-
getBounds
Return this variable's current bounds.- Returns:
- this variable's current bounds
-
initialBounds
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
Returns the invocation tree.- Returns:
- the invocation tree
-
equals
-
hashCode
public int hashCode() -
toString
-
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
The Java type variable.- Returns:
- the Java type variable
-