boolean (Set<PsiTypeParameter> capturedSuperClassTypes, PsiClass superClass, PsiClass derivedClass) { if (capturedSuperClassTypes.isEmpty()) { return true; } PsiSubstitutor substitutor = TypeConversionUtil.getSuperClassSubstitutor(superClass, derivedClass, PsiSubstitutor.EMPTY); if (substitutor == PsiSubstitutor.EMPTY) { return true; } Set<String> capturedSourceTypeParameters = new HashSet<>(); for (PsiTypeParameter parameter : PsiUtil.typeParametersIterable(superClass)) { if (!capturedSuperClassTypes.contains(parameter)) { continue; } PsiType substituted = substitutor.substitute(parameter); if (!(substituted instanceof PsiClassType)) { continue; } PsiClass resolved = ((PsiClassType)substituted).resolve(); if (!(resolved instanceof PsiTypeParameter)) { continue; } PsiTypeParameter typeParameter = (PsiTypeParameter)resolved; if (capturedSourceTypeParameters.contains(typeParameter.getName())) { return false; } capturedSourceTypeParameters.add(typeParameter.getName()); } return true; }