Lines 533-557
Link Here
|
533 |
((BinaryTypeBinding) inheritedMethod.declaringClass).resolveTypesFor(inheritedMethod); |
533 |
((BinaryTypeBinding) inheritedMethod.declaringClass).resolveTypesFor(inheritedMethod); |
534 |
|
534 |
|
535 |
TypeVariableBinding[] inheritedTypeVariables = inheritedMethod.typeVariables; |
535 |
TypeVariableBinding[] inheritedTypeVariables = inheritedMethod.typeVariables; |
536 |
if (inheritedTypeVariables == Binding.NO_TYPE_VARIABLES) return inheritedMethod; |
|
|
537 |
int inheritedLength = inheritedTypeVariables.length; |
536 |
int inheritedLength = inheritedTypeVariables.length; |
|
|
537 |
if (inheritedLength == 0) return inheritedMethod; // no substitution needed |
538 |
TypeVariableBinding[] typeVariables = currentMethod.typeVariables; |
538 |
TypeVariableBinding[] typeVariables = currentMethod.typeVariables; |
539 |
int length = typeVariables.length; |
539 |
int length = typeVariables.length; |
540 |
if (length > 0 && inheritedLength != length) return inheritedMethod; // no match JLS 8.4.2 |
540 |
if (length == 0) |
541 |
TypeBinding[] arguments = new TypeBinding[inheritedLength]; |
541 |
return inheritedMethod.asRawMethod(this.environment); |
542 |
if (inheritedLength <= length) { |
542 |
if (length != inheritedLength) |
543 |
System.arraycopy(typeVariables, 0, arguments, 0, inheritedLength); |
543 |
return inheritedMethod; // no match JLS 8.4.2 |
544 |
} else { |
|
|
545 |
System.arraycopy(typeVariables, 0, arguments, 0, length); |
546 |
for (int i = length; i < inheritedLength; i++) |
547 |
arguments[i] = inheritedTypeVariables[i].upperBound(); |
548 |
} |
549 |
ParameterizedGenericMethodBinding substitute = |
550 |
this.environment.createParameterizedGenericMethod(inheritedMethod, arguments); |
551 |
|
544 |
|
552 |
// interface I { <T> void foo(T t); } |
545 |
// interface I { <T> void foo(T t); } |
553 |
// class X implements I { public <T extends I> void foo(T t) {} } |
546 |
// class X implements I { public <T extends I> void foo(T t) {} } |
554 |
// for the above case, we do not want to answer the substitute method since its not a match |
547 |
// for the above case, we do not want to answer the substitute method since its not a match |
|
|
548 |
TypeBinding[] arguments = new TypeBinding[length]; |
549 |
System.arraycopy(typeVariables, 0, arguments, 0, length); |
550 |
ParameterizedGenericMethodBinding substitute = |
551 |
this.environment.createParameterizedGenericMethod(inheritedMethod, arguments); |
555 |
for (int i = 0; i < inheritedLength; i++) { |
552 |
for (int i = 0; i < inheritedLength; i++) { |
556 |
TypeVariableBinding inheritedTypeVariable = inheritedTypeVariables[i]; |
553 |
TypeVariableBinding inheritedTypeVariable = inheritedTypeVariables[i]; |
557 |
TypeBinding argument = arguments[i]; |
554 |
TypeBinding argument = arguments[i]; |