Lines 516-540
Link Here
|
516 |
((BinaryTypeBinding) inheritedMethod.declaringClass).resolveTypesFor(inheritedMethod); |
516 |
((BinaryTypeBinding) inheritedMethod.declaringClass).resolveTypesFor(inheritedMethod); |
517 |
|
517 |
|
518 |
TypeVariableBinding[] inheritedTypeVariables = inheritedMethod.typeVariables; |
518 |
TypeVariableBinding[] inheritedTypeVariables = inheritedMethod.typeVariables; |
519 |
if (inheritedTypeVariables == Binding.NO_TYPE_VARIABLES) return inheritedMethod; |
|
|
520 |
int inheritedLength = inheritedTypeVariables.length; |
519 |
int inheritedLength = inheritedTypeVariables.length; |
|
|
520 |
if (inheritedLength == 0) return inheritedMethod; // no substitution needed |
521 |
TypeVariableBinding[] typeVariables = currentMethod.typeVariables; |
521 |
TypeVariableBinding[] typeVariables = currentMethod.typeVariables; |
522 |
int length = typeVariables.length; |
522 |
int length = typeVariables.length; |
523 |
if (length > 0 && inheritedLength != length) return inheritedMethod; // no match JLS 8.4.2 |
523 |
if (length == 0) |
524 |
TypeBinding[] arguments = new TypeBinding[inheritedLength]; |
524 |
return inheritedMethod.asRawMethod(this.environment); |
525 |
if (inheritedLength <= length) { |
525 |
if (length != inheritedLength) |
526 |
System.arraycopy(typeVariables, 0, arguments, 0, inheritedLength); |
526 |
return inheritedMethod; // no match JLS 8.4.2 |
527 |
} else { |
|
|
528 |
System.arraycopy(typeVariables, 0, arguments, 0, length); |
529 |
for (int i = length; i < inheritedLength; i++) |
530 |
arguments[i] = inheritedTypeVariables[i].upperBound(); |
531 |
} |
532 |
ParameterizedGenericMethodBinding substitute = |
533 |
this.environment.createParameterizedGenericMethod(inheritedMethod, arguments); |
534 |
|
527 |
|
535 |
// interface I { <T> void foo(T t); } |
528 |
// interface I { <T> void foo(T t); } |
536 |
// class X implements I { public <T extends I> void foo(T t) {} } |
529 |
// class X implements I { public <T extends I> void foo(T t) {} } |
537 |
// for the above case, we do not want to answer the substitute method since its not a match |
530 |
// for the above case, we do not want to answer the substitute method since its not a match |
|
|
531 |
TypeBinding[] arguments = new TypeBinding[length]; |
532 |
System.arraycopy(typeVariables, 0, arguments, 0, length); |
533 |
ParameterizedGenericMethodBinding substitute = |
534 |
this.environment.createParameterizedGenericMethod(inheritedMethod, arguments); |
538 |
for (int i = 0; i < inheritedLength; i++) { |
535 |
for (int i = 0; i < inheritedLength; i++) { |
539 |
TypeVariableBinding inheritedTypeVariable = inheritedTypeVariables[i]; |
536 |
TypeVariableBinding inheritedTypeVariable = inheritedTypeVariables[i]; |
540 |
TypeBinding argument = arguments[i]; |
537 |
TypeBinding argument = arguments[i]; |
Lines 562-568
Link Here
|
562 |
return inheritedMethod; // not a match |
559 |
return inheritedMethod; // not a match |
563 |
} |
560 |
} |
564 |
} else if (inheritedTypeVariable.boundCheck(substitute, argument) != TypeConstants.OK) { |
561 |
} else if (inheritedTypeVariable.boundCheck(substitute, argument) != TypeConstants.OK) { |
565 |
return inheritedMethod; |
562 |
return inheritedMethod; |
566 |
} |
563 |
} |
567 |
} |
564 |
} |
568 |
return substitute; |
565 |
return substitute; |