}
/** 在context中查找类型变量对应的实际类型。 */
static TypeInfo resolveTypeVariable(TypeVariableInfo var, GenericDeclarationInfo context, boolean includeBaseType) {
GenericDeclarationInfo declaration = assertNotNull(var, "var").getGenericDeclaration();
TypeInfo result = null;
// 当前var的declaration可能是: Class,带类型参数的method,带类型参数的constructor。
//
// 情形1. delcaration是Class,context也是Class,则在context.
// supertypes中查找和declaration匹配的type
if (declaration instanceof ClassTypeInfo && context instanceof ClassTypeInfo) {
TypeInfo declarationEquivalent = findSupertype((ClassTypeInfo) context,
((ClassTypeInfo) declaration).getRawType());
if (declarationEquivalent != null) {
if (!includeBaseType && declarationEquivalent instanceof RawTypeInfo) {
result = var;
} else {
TypeInfo declarationResolved = declarationEquivalent.resolve(context, includeBaseType);
assertTrue(declarationResolved instanceof GenericDeclarationInfo,
"Unexpected declarationResolved: %s", declarationResolved);
result = ((GenericDeclarationInfo) declarationResolved).getActualTypeArgument(var.getName());