PsiSubstitutor (final PsiClass psiClass, final PsiSubstitutor parentSubstitutor) { final Map<PsiTypeParameter, PsiType> substitutionMap = parentSubstitutor.getSubstitutionMap(); final List<PsiType> result = new ArrayList<>(substitutionMap.size()); for (PsiTypeParameter typeParameter : psiClass.getTypeParameters()) { final String name = typeParameter.getName(); final PsiTypeParameter key = ContainerUtil.find(substitutionMap.keySet(), psiTypeParameter -> name.equals(psiTypeParameter.getName())); if (key != null) { result.add(substitutionMap.get(key)); } } return PsiSubstitutor.EMPTY.putAll(psiClass, result.toArray(PsiType.createArray(result.size()))); }