Lines 115-124
Link Here
|
115 |
public void initializeBounds(ParameterizedTypeBinding capturedParameterizedType) { |
115 |
public void initializeBounds(ParameterizedTypeBinding capturedParameterizedType) { |
116 |
TypeVariableBinding wildcardVariable = wildcard.typeVariable(); |
116 |
TypeVariableBinding wildcardVariable = wildcard.typeVariable(); |
117 |
ReferenceBinding originalVariableSuperclass = wildcardVariable.superclass; |
117 |
ReferenceBinding originalVariableSuperclass = wildcardVariable.superclass; |
|
|
118 |
ReferenceBinding substitutedVariableSuperclass = (ReferenceBinding) Scope.substitute(capturedParameterizedType, originalVariableSuperclass); |
118 |
// prevent cyclic capture: given X<T>, capture(X<? extends T> could yield a circular type |
119 |
// prevent cyclic capture: given X<T>, capture(X<? extends T> could yield a circular type |
119 |
ReferenceBinding substitutedVariableSuperclass = originalVariableSuperclass.isTypeVariable() ? originalVariableSuperclass : (ReferenceBinding) Scope.substitute(capturedParameterizedType, originalVariableSuperclass); |
120 |
if (substitutedVariableSuperclass == this) substitutedVariableSuperclass = originalVariableSuperclass; |
120 |
ReferenceBinding[] substitutedVariableInterfaces = Scope.substitute(capturedParameterizedType, wildcardVariable.superInterfaces()); |
|
|
121 |
|
121 |
|
|
|
122 |
ReferenceBinding[] originalVariableInterfaces = wildcardVariable.superInterfaces(); |
123 |
ReferenceBinding[] substitutedVariableInterfaces = Scope.substitute(capturedParameterizedType, originalVariableInterfaces); |
124 |
if (substitutedVariableInterfaces != originalVariableInterfaces) { |
125 |
// prevent cyclic capture: given X<T>, capture(X<? extends T> could yield a circular type |
126 |
for (int i = 0, length = substitutedVariableInterfaces.length; i < length; i++) { |
127 |
if (substitutedVariableInterfaces[i] == this) substitutedVariableInterfaces[i] = originalVariableInterfaces[i]; |
128 |
} |
129 |
} |
122 |
switch (wildcard.boundKind) { |
130 |
switch (wildcard.boundKind) { |
123 |
case Wildcard.EXTENDS : |
131 |
case Wildcard.EXTENDS : |
124 |
if (wildcard.bound.isInterface()) { |
132 |
if (wildcard.bound.isInterface()) { |
Lines 138-143
Link Here
|
138 |
this.superInterfaces = substitutedVariableInterfaces; |
146 |
this.superInterfaces = substitutedVariableInterfaces; |
139 |
} |
147 |
} |
140 |
TypeBinding substitutedWildcardBound = Scope.substitute(capturedParameterizedType, wildcard.bound); |
148 |
TypeBinding substitutedWildcardBound = Scope.substitute(capturedParameterizedType, wildcard.bound); |
|
|
149 |
// prevent cyclic capture: given X<T>, capture(X<? extends T> could yield a circular type |
150 |
if (substitutedWildcardBound == this) substitutedWildcardBound = wildcard.bound; |
141 |
this.firstBound = substitutedWildcardBound; |
151 |
this.firstBound = substitutedWildcardBound; |
142 |
if ((substitutedWildcardBound.tagBits & HasTypeVariable) == 0) |
152 |
if ((substitutedWildcardBound.tagBits & HasTypeVariable) == 0) |
143 |
this.tagBits &= ~HasTypeVariable; |
153 |
this.tagBits &= ~HasTypeVariable; |
Lines 149-156
Link Here
|
149 |
break; |
159 |
break; |
150 |
case Wildcard.SUPER : |
160 |
case Wildcard.SUPER : |
151 |
this.superclass = substitutedVariableSuperclass; |
161 |
this.superclass = substitutedVariableSuperclass; |
152 |
// prevent cyclic capture: given X<T>, capture(X<? super T> could yield a circular type |
162 |
substitutedWildcardBound = Scope.substitute(capturedParameterizedType, wildcard.bound); |
153 |
substitutedWildcardBound = wildcard.bound.isTypeVariable() ? wildcard.bound : Scope.substitute(capturedParameterizedType, wildcard.bound); |
163 |
// prevent cyclic capture: given X<T>, capture(X<? extends T> could yield a circular type |
|
|
164 |
if (substitutedWildcardBound == this) substitutedWildcardBound = wildcard.bound; |
165 |
|
154 |
if (wildcardVariable.firstBound == this.superclass |
166 |
if (wildcardVariable.firstBound == this.superclass |
155 |
|| substitutedWildcardBound == this.superclass) { |
167 |
|| substitutedWildcardBound == this.superclass) { |
156 |
this.firstBound = this.superclass; |
168 |
this.firstBound = this.superclass; |