Index: CaptureBinding.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java,v retrieving revision 1.8 diff -u -r1.8 CaptureBinding.java --- CaptureBinding.java 9 Jun 2005 11:44:54 -0000 1.8 +++ CaptureBinding.java 15 Jun 2005 11:06:34 -0000 @@ -115,10 +115,18 @@ public void initializeBounds(ParameterizedTypeBinding capturedParameterizedType) { TypeVariableBinding wildcardVariable = wildcard.typeVariable(); ReferenceBinding originalVariableSuperclass = wildcardVariable.superclass; + ReferenceBinding substitutedVariableSuperclass = (ReferenceBinding) Scope.substitute(capturedParameterizedType, originalVariableSuperclass); // prevent cyclic capture: given X, capture(X could yield a circular type - ReferenceBinding substitutedVariableSuperclass = originalVariableSuperclass.isTypeVariable() ? originalVariableSuperclass : (ReferenceBinding) Scope.substitute(capturedParameterizedType, originalVariableSuperclass); - ReferenceBinding[] substitutedVariableInterfaces = Scope.substitute(capturedParameterizedType, wildcardVariable.superInterfaces()); + if (substitutedVariableSuperclass == this) substitutedVariableSuperclass = originalVariableSuperclass; + ReferenceBinding[] originalVariableInterfaces = wildcardVariable.superInterfaces(); + ReferenceBinding[] substitutedVariableInterfaces = Scope.substitute(capturedParameterizedType, originalVariableInterfaces); + if (substitutedVariableInterfaces != originalVariableInterfaces) { + // prevent cyclic capture: given X, capture(X could yield a circular type + for (int i = 0, length = substitutedVariableInterfaces.length; i < length; i++) { + if (substitutedVariableInterfaces[i] == this) substitutedVariableInterfaces[i] = originalVariableInterfaces[i]; + } + } switch (wildcard.boundKind) { case Wildcard.EXTENDS : if (wildcard.bound.isInterface()) { @@ -138,6 +146,8 @@ this.superInterfaces = substitutedVariableInterfaces; } TypeBinding substitutedWildcardBound = Scope.substitute(capturedParameterizedType, wildcard.bound); + // prevent cyclic capture: given X, capture(X could yield a circular type + if (substitutedWildcardBound == this) substitutedWildcardBound = wildcard.bound; this.firstBound = substitutedWildcardBound; if ((substitutedWildcardBound.tagBits & HasTypeVariable) == 0) this.tagBits &= ~HasTypeVariable; @@ -149,8 +159,10 @@ break; case Wildcard.SUPER : this.superclass = substitutedVariableSuperclass; - // prevent cyclic capture: given X, capture(X could yield a circular type - substitutedWildcardBound = wildcard.bound.isTypeVariable() ? wildcard.bound : Scope.substitute(capturedParameterizedType, wildcard.bound); + substitutedWildcardBound = Scope.substitute(capturedParameterizedType, wildcard.bound); + // prevent cyclic capture: given X, capture(X could yield a circular type + if (substitutedWildcardBound == this) substitutedWildcardBound = wildcard.bound; + if (wildcardVariable.firstBound == this.superclass || substitutedWildcardBound == this.superclass) { this.firstBound = this.superclass;