Package com.google.auto.common
Class Overrides.ExplicitOverrides.TypeSubstVisitor
java.lang.Object
javax.lang.model.util.AbstractTypeVisitor6<R,P>
javax.lang.model.util.SimpleTypeVisitor6<R,P>
javax.lang.model.util.SimpleTypeVisitor7<R,P>
javax.lang.model.util.SimpleTypeVisitor8<TypeMirror,Void>
com.google.auto.common.Overrides.ExplicitOverrides.TypeSubstVisitor
- All Implemented Interfaces:
TypeVisitor<TypeMirror,
Void>
- Enclosing class:
- Overrides.ExplicitOverrides
private class Overrides.ExplicitOverrides.TypeSubstVisitor
extends SimpleTypeVisitor8<TypeMirror,Void>
Visitor that replaces type variables with their values in the types it sees. If we know
that
E
is String
, then we can return String
for E
,
List<String>
for List<E>
, String[]
for E[]
, etc. We don't
have to cover all types here because (1) the type is going to end up being erased, and
(2) wildcards can't appear in direct supertypes. So for example it is illegal to write
class MyList implements List<? extends Number>
. It's legal to write
class MyList implements List<Set<? extends Number>>
but that doesn't matter
because the E
of the List
is going to be erased to raw Set
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<TypeParameterElement,
TypeMirror> The bindings of type variables.Fields inherited from class javax.lang.model.util.SimpleTypeVisitor6
DEFAULT_VALUE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected TypeMirror
defaultAction
(TypeMirror e, Void p) (package private) com.google.common.collect.ImmutableList<TypeMirror>
erasedParameterTypes
(ExecutableElement method, TypeElement in) visitArray
(ArrayType t, Void p) visitDeclared
(DeclaredType t, Void p) Methods inherited from class javax.lang.model.util.SimpleTypeVisitor8
visitIntersection
Methods inherited from class javax.lang.model.util.SimpleTypeVisitor7
visitUnion
Methods inherited from class javax.lang.model.util.SimpleTypeVisitor6
visitError, visitExecutable, visitNoType, visitNull, visitPrimitive, visitWildcard
Methods inherited from class javax.lang.model.util.AbstractTypeVisitor6
visit, visit, visitUnknown
-
Field Details
-
typeBindings
The bindings of type variables. We can put them all in one map because E inList<E>
is not the same as E inCollection<E>
. As we ascend the type hierarchy we'll add mappings for all the variables we see. We could equivalently create a new map for each type we visit, but this is slightly simpler and probably about as performant.
-
-
Constructor Details
-
TypeSubstVisitor
private TypeSubstVisitor()
-
-
Method Details
-
erasedParameterTypes
com.google.common.collect.ImmutableList<TypeMirror> erasedParameterTypes(ExecutableElement method, TypeElement in) -
defaultAction
- Overrides:
defaultAction
in classSimpleTypeVisitor6<TypeMirror,
Void>
-
visitTypeVariable
- Specified by:
visitTypeVariable
in interfaceTypeVisitor<TypeMirror,
Void> - Overrides:
visitTypeVariable
in classSimpleTypeVisitor6<TypeMirror,
Void>
-
visitDeclared
- Specified by:
visitDeclared
in interfaceTypeVisitor<TypeMirror,
Void> - Overrides:
visitDeclared
in classSimpleTypeVisitor6<TypeMirror,
Void>
-
visitArray
- Specified by:
visitArray
in interfaceTypeVisitor<TypeMirror,
Void> - Overrides:
visitArray
in classSimpleTypeVisitor6<TypeMirror,
Void>
-