diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java index 7f1accc7b802..988cd9755cca 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java @@ -427,16 +427,17 @@ public class InferenceSession { inferenceVariable.setInstantiation(null); continue; } - PsiType bound = null; - for (PsiType eqBound : eqBounds) { - if (eqBound == null) continue; - if (bound != null && !isProperType(eqBound)) continue; - bound = acceptBoundsWithRecursiveDependencies(typeParameter, eqBound, substitutor); - } - if (bound != null) { - if (bound instanceof PsiCapturedWildcardType && eqBounds.size() > 1) { - continue; + if (eqBounds.size() > 1) { + for (Iterator iterator = eqBounds.iterator(); iterator.hasNext(); ) { + PsiType eqBound = iterator.next(); + if (PsiUtil.resolveClassInType(eqBound) == typeParameter) { + iterator.remove(); + } } + if (eqBounds.size() > 1) continue; + } + PsiType bound = eqBounds.isEmpty() ? null : acceptBoundsWithRecursiveDependencies(typeParameter, eqBounds.get(0), substitutor); + if (bound != null) { inferenceVariable.setInstantiation(bound); } else { PsiType lub = null;