Class TypeVariableSubstitutor
java.lang.Object
org.checkerframework.framework.type.TypeVariableSubstitutor
TypeVariableSubstitutor replaces type variables from a declaration with arguments to its use.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
Visitor that makes the substitution. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionsubstitute
(Map<TypeVariable, AnnotatedTypeMirror> typeVarToTypeArgument, AnnotatedTypeMirror type) Given a mapping from type variable to its type argument, replace each instance of a type variable with a copy of type argument.protected AnnotatedTypeMirror
Given the types of a type parameter declaration, the argument to that type parameter declaration, and a given use of that declaration, return a substitute for the use with the correct annotations.substituteWithoutCopyingTypeArguments
(Map<TypeVariable, AnnotatedTypeMirror> typeVarToTypeArgument, AnnotatedTypeMirror type) Given a mapping from type variable to its type argument, replace each instance of a type variable with the given type argument.
-
Constructor Details
-
TypeVariableSubstitutor
public TypeVariableSubstitutor()Create a TypeVariableSubstitutor.
-
-
Method Details
-
substitute
public AnnotatedTypeMirror substitute(Map<TypeVariable, AnnotatedTypeMirror> typeVarToTypeArgument, AnnotatedTypeMirror type) Given a mapping from type variable to its type argument, replace each instance of a type variable with a copy of type argument.- Parameters:
typeVarToTypeArgument
- a mapping from type variable to its type argumenttype
- the type to substitute- Returns:
- a copy of type with its type variables substituted
- See Also:
-
substituteWithoutCopyingTypeArguments
public AnnotatedTypeMirror substituteWithoutCopyingTypeArguments(Map<TypeVariable, AnnotatedTypeMirror> typeVarToTypeArgument, AnnotatedTypeMirror type) Given a mapping from type variable to its type argument, replace each instance of a type variable with the given type argument.- Parameters:
typeVarToTypeArgument
- a mapping from type variable to its type argumenttype
- the type to substitute- Returns:
- a copy of type with its type variables substituted
- See Also:
-
substituteTypeVariable
protected AnnotatedTypeMirror substituteTypeVariable(AnnotatedTypeMirror argument, AnnotatedTypeMirror.AnnotatedTypeVariable use) Given the types of a type parameter declaration, the argument to that type parameter declaration, and a given use of that declaration, return a substitute for the use with the correct annotations.To determine what primary annotations are correct for the substitute the following rules are used: If the type variable use has a primary annotation then apply that primary annotation to the substitute. Otherwise, use the annotations of the argument.
- Parameters:
argument
- the argument to declaration (this will be a value in typeParamToArg)use
- the use that is being replaced- Returns:
- a deep copy of argument with the appropriate annotations applied
-