PsiTypeParameter (@NotNull JVMElementFactory factory, @NotNull PsiTypeParameterList sourceTypeParameterList, @Nullable PsiElement target, @NotNull PsiTypeParameter typeParam, @NotNull PsiSubstitutor substitutor) { String typeParamName = typeParam.getName(); for (PsiType type : substitutor.getSubstitutionMap().values()) { if (type != null && Objects.equals(type.getCanonicalText(), typeParamName)) { final String newName = suggestUniqueTypeParameterName(typeParamName, sourceTypeParameterList, PsiTreeUtil.getParentOfType(target, PsiClass.class, false)); final PsiTypeParameter newTypeParameter = factory.createTypeParameter(newName, typeParam.getSuperTypes()); substitutor.put(typeParam, factory.createType(newTypeParameter)); return newTypeParameter; } } return factory.createTypeParameter(typeParamName, typeParam.getSuperTypes()); }