PsiSubstitutor (@NotNull PsiSubstitutor substitutor) { Map<PsiTypeParameter, PsiType> map = null; for (Map.Entry<PsiTypeParameter, PsiType> entry : substitutor.getSubstitutionMap().entrySet()) { if (entry.getValue() == null) { if (map == null) map = new HashMap<>(); map.put(entry.getKey(), entry.getValue()); } } if (map == null) return substitutor; Map<PsiTypeParameter, PsiType> newMap = new HashMap<>(substitutor.getSubstitutionMap()); newMap.keySet().removeAll(map.keySet()); return PsiSubstitutor.createSubstitutor(newMap); }