Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java,v retrieving revision 1.37 diff -u -r1.37 MethodVerifier15.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 24 May 2005 17:20:42 -0000 1.37 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 7 Jun 2005 13:35:09 -0000 @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.jdt.internal.compiler.lookup; +import org.eclipse.jdt.internal.compiler.ast.MessageSend; import org.eclipse.jdt.internal.compiler.util.HashtableOfObject; class MethodVerifier15 extends MethodVerifier { @@ -317,22 +318,14 @@ if (inheritedTypeVariables == NoTypeVariables) return inheritedMethod; TypeVariableBinding[] typeVariables = currentMethod == null ? NoTypeVariables : currentMethod.typeVariables; - int inheritedLength = inheritedTypeVariables.length; - int length = typeVariables.length; - TypeBinding[] arguments = new TypeBinding[inheritedLength]; - if (inheritedLength <= length) { - System.arraycopy(typeVariables, 0, arguments, 0, inheritedLength); - } else { - System.arraycopy(typeVariables, 0, arguments, 0, length); - for (int i = length; i < inheritedLength; i++) - arguments[i] = inheritedTypeVariables[i].erasure(); - } - ParameterizedGenericMethodBinding substitute = - new ParameterizedGenericMethodBinding(inheritedMethod, arguments, this.environment); - for (int i = 0; i < inheritedLength; i++) - if (inheritedTypeVariables[i].boundCheck(substitute, arguments[i]) != TypeConstants.OK) - return inheritedMethod; // incompatible due to bound check - return substitute; + if (inheritedMethod.parameters.length != currentMethod.parameters.length) return inheritedMethod; + + MessageSend invocationSite = new MessageSend(); + if (currentMethod.returnType instanceof ReferenceBinding) { + invocationSite.expectedType = ((ReferenceBinding)currentMethod.returnType).findSuperTypeWithSameErasure(inheritedMethod.returnType); + } + MethodBinding substitute = ParameterizedGenericMethodBinding.computeCompatibleMethod(inheritedMethod, currentMethod.parameters, this.type.scope, invocationSite); + return substitute == null ? inheritedMethod : substitute; } boolean detectInheritedMethodClash(MethodBinding inherited, MethodBinding otherInherited) { if (!inherited.areParameterErasuresEqual(otherInherited) || inherited.returnType.erasure() != otherInherited.returnType.erasure()) return false; Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java,v retrieving revision 1.36 diff -u -r1.36 ParameterizedGenericMethodBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java 3 Jun 2005 10:21:28 -0000 1.36 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java 7 Jun 2005 13:35:09 -0000 @@ -367,15 +367,15 @@ return this.originalMethod.hasSubstitutedParameters(); return super.hasSubstitutedParameters(); } - /** - * Returns true if the return type got substituted. - * NOTE: generic method invocation delegates to its declaring method (could be a parameterized one) - */ - public boolean hasSubstitutedReturnType() { - if (this.inferredReturnType) - return this.originalMethod.hasSubstitutedReturnType(); - return super.hasSubstitutedReturnType(); - } +// /** +// * Returns true if the return type got substituted. +// * NOTE: generic method invocation delegates to its declaring method (could be a parameterized one) +// */ +// public boolean hasSubstitutedReturnType() { +// if (this.inferredReturnType) +// return this.originalMethod.hasSubstitutedReturnType(); +// return super.hasSubstitutedReturnType(); +// } /** * Given some type expectation, and type variable bounds, perform some inference. * Returns true if still had unresolved type variable at the end of the operation