Class Theta
Two type variables are the same key if TypesUtils.areSame(TypeVariable, TypeVariable)
returns true for them; they need not be the same object. (Two objects for the same type variable
arise when a type has undergone type variable substitution, or when the type variable is the type
of a tree created by TreeBuilder.) That is why this
class is not a Map: a Map would compare keys using TypeVariable.equals,
which javac's Type.TypeVar does not override and which is therefore reference equality.
Iteration order is insertion order, as for LinkedHashMap.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsValue(Variable variable) Returns true ifvariableis the inference variable for some type variable.get(TypeMirror type) Returns the inference variable fortype, or null if there is none.Collection<? extends TypeVariable> Returns the type variables that do not yet have a value, in the order in which they were added.Collection<? extends TypeVariable> Returns the type variables that have an inference variable, in the order in which they were added.put(TypeVariable typeVariable, Variable variable) MapstypeVariabletovariable.toString()values()Returns the inference variables, in the order in which they were added.
-
Constructor Details
-
Theta
public Theta()Creates Theta.
-
-
Method Details
-
put
MapstypeVariabletovariable. If some type variable that isTypesUtils.areSame(TypeVariable, TypeVariable)astypeVariableis already mapped, then its inference variable is replaced, butgetTypeVariables()continues to return the type variable that was passed to the earlier call. That distinction does not matter to clients, which compare type variables usingareSame.Callers that iterate over
values()in lockstep with the type variables they passed to this method, such asCaptureBound, depend on each call adding an entry rather than replacing one. That holds because the type variables of a single declaration have distinct simple names and the same enclosing element, so no two of them areareSame.- Parameters:
typeVariable- a type variablevariable- the inference variable fortypeVariable- Returns:
- the inference variable that
typeVariablewas previously mapped to, or null if it was not mapped
-
get
Returns the inference variable fortype, or null if there is none.typeneed not be the same object as the type variable that was passed toput(javax.lang.model.type.TypeVariable, org.checkerframework.framework.util.typeinference8.types.Variable); it is enough that the two areTypesUtils.areSame(TypeVariable, TypeVariable).- Parameters:
type- a type; if it is not a type variable, then this method returns null- Returns:
- the inference variable for
type, or null if there is none
-
containsValue
Returns true ifvariableis the inference variable for some type variable.- Parameters:
variable- an inference variable- Returns:
- true if
variableis the inference variable for some type variable
-
values
Returns the inference variables, in the order in which they were added. The result is unmodifiable.- Returns:
- the inference variables, in the order in which they were added
-
getTypeVariables
Returns the type variables that have an inference variable, in the order in which they were added. The result is unmodifiable.The result's
containsmethod usesequals, which for a type variable is reference equality. A client that wants this class's notion of key equality must compare the elements usingTypesUtils.areSame(TypeVariable, TypeVariable)itself, or callget(javax.lang.model.type.TypeMirror).- Returns:
- the type variables that have an inference variable
-
getNotInstantiated
Returns the type variables that do not yet have a value, in the order in which they were added. UnlikegetTypeVariables(), the result is not cached, because a type variable acquires a value without any call toput(javax.lang.model.type.TypeVariable, org.checkerframework.framework.util.typeinference8.types.Variable).- Returns:
- the type variables that do not yet have a value
-
toString
-