Source:
private Map<Name, TypeElement> parseTypeParameters(TypeMirror mirror) { Map<Name, TypeElement> typeParameters = Maps.newHashMap(); Map<Name, TypeElement> childTypeParameters = typeMappingsForInterface.getOrDefault(mirror, Collections.emptyMap()); if (mirror instanceof DeclaredType) { TypeElement element = (TypeElement) context.getTypeUtils().asElement(mirror); DeclaredType declaredType = (DeclaredType) mirror; for (int i = 0; i < declaredType.getTypeArguments().size() && i < element.getTypeParameters().size(); i++) { Name name = element.getTypeParameters().get(i).getSimpleName(); TypeMirror typeArgument = declaredType.getTypeArguments().get(i); if (typeArgument instanceof DeclaredType) { Element concreteType = ((DeclaredType) typeArgument).asElement(); typeParameters.put(name, (TypeElement) concreteType); } else if (typeArgument instanceof TypeVariable) { TypeVariable genericType = (TypeVariable) typeArgument; Name previousName = genericType.asElement().getSimpleName(); if (childTypeParameters.containsKey(previousName)) { typeParameters.put(name, childTypeParameters.get(previousName)); } else { context .getMessager() .error( element, "Could not resolve type parameter %s " + "on %s from child interfaces. This error usually means an interface " + "was inappropriately annotated with @Dao. Interfaces should only be annotated " + "with @Dao if all generic type variables are declared.", name, mirror); } } } for (TypeMirror parentInterface : element.getInterfaces()) { if (parentInterface instanceof DeclaredType) { Map<Name, TypeElement> typeMappingsForParent = typeMappingsForInterface.computeIfAbsent(parentInterface, k -> Maps.newHashMap()); DeclaredType parentInterfaceType = (DeclaredType) parentInterface; for (TypeMirror parentTypeArgument : parentInterfaceType.getTypeArguments()) { if (parentTypeArgument instanceof TypeVariable) { TypeVariable parentTypeVariable = (TypeVariable) parentTypeArgument; Name parentTypeName = parentTypeVariable.asElement().getSimpleName(); TypeElement typeElement = typeParameters.get(parentTypeName); if (typeElement != null) { typeMappingsForParent.put(parentTypeName, typeElement); } } } } } } return typeParameters; }

Target:
private Map<Name, TypeElement> parseTypeParameters(TypeMirror mirror) { Map<Name, TypeElement> typeParameters = Maps.newHashMap(); Map<Name, TypeElement> childTypeParameters = typeMappingsForInterface.getOrDefault(mirror, Collections.emptyMap()); if (mirror instanceof DeclaredType) { TypeElement element = (TypeElement) context.getTypeUtils().asElement(mirror); DeclaredType declaredType = (DeclaredType) mirror; for (int i = 0; i < declaredType.getTypeArguments().size(); i++) { Name name = element.getTypeParameters().get(i).getSimpleName(); TypeMirror typeArgument = declaredType.getTypeArguments().get(i); if (typeArgument instanceof DeclaredType) { Element concreteType = ((DeclaredType) typeArgument).asElement(); typeParameters.put(name, (TypeElement) concreteType); } else if (typeArgument instanceof TypeVariable) { Name typeVariableName = ((TypeVariable) typeArgument).asElement().getSimpleName(); if (childTypeParameters.containsKey(typeVariableName)) { typeParameters.put(name, childTypeParameters.get(typeVariableName)); } else { context .getMessager() .error( element, "Could not resolve type parameter %s " + "on %s from child interfaces. This error usually means an interface " + "was inappropriately annotated with @%s. Interfaces should only be annotated " + "with @%s if all generic type variables are declared.", name, mirror, Dao.class.getSimpleName(), Dao.class.getSimpleName()); } } } for (TypeMirror parentInterface : element.getInterfaces()) { if (parentInterface instanceof DeclaredType) { Map<Name, TypeElement> typeMappingsForParent = typeMappingsForInterface.computeIfAbsent(parentInterface, k -> Maps.newHashMap()); DeclaredType parentInterfaceType = (DeclaredType) parentInterface; for (TypeMirror parentTypeArgument : parentInterfaceType.getTypeArguments()) { if (parentTypeArgument instanceof TypeVariable) { TypeVariable parentTypeVariable = (TypeVariable) parentTypeArgument; Name parentTypeName = parentTypeVariable.asElement().getSimpleName(); TypeElement typeElement = typeParameters.get(parentTypeName); if (typeElement != null) { typeMappingsForParent.put(parentTypeName, typeElement); } } } } } } return typeParameters; }