PsiSubstitutor () { JavaResolveResult resolveResult = myCall.resolveMethodGenerics(); if (myMethod.isPhysical()) { // Could be specialized LOG.assertTrue(myManager.areElementsEquivalent(resolveResult.getElement(), myMethod)); } if (resolveResult.getSubstitutor() != PsiSubstitutor.EMPTY) { Iterator<PsiTypeParameter> oldTypeParameters = PsiUtil.typeParametersIterator(myMethod); Iterator<PsiTypeParameter> newTypeParameters = PsiUtil.typeParametersIterator(myMethodCopy); PsiSubstitutor substitutor = resolveResult.getSubstitutor(); while (newTypeParameters.hasNext()) { final PsiTypeParameter newTypeParameter = newTypeParameters.next(); final PsiTypeParameter oldTypeParameter = oldTypeParameters.next(); substitutor = substitutor.put(newTypeParameter, resolveResult.getSubstitutor().substitute(oldTypeParameter)); } return substitutor; } return PsiSubstitutor.EMPTY; }