boolean (@NotNull PsiMethod method, @NotNull PsiType returnType, @NotNull PsiTypeParameter typeParameter, @NotNull PsiSubstitutor superClassSubstitutor) { PsiClass containingClass = method.getContainingClass(); if (containingClass == null || !(returnType instanceof PsiClassType) || !containingClass.equals(((PsiClassType)returnType).resolve())) { return false; } PsiTypeParameterListOwner typeParameterOwner = typeParameter.getOwner(); PsiTypeParameterList typeParameterList = typeParameterOwner == null ? null : typeParameterOwner.getTypeParameterList(); int index = typeParameterList == null ? -1 : typeParameterList.getTypeParameterIndex(typeParameter); PsiType[] parameters = ((PsiClassType)returnType).getParameters(); if (index == -1 || parameters.length <= index) return false; return typeResolvesTo(parameters[index], typeParameter, superClassSubstitutor); }