### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java,v retrieving revision 1.98 diff -u -r1.98 BinaryTypeBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java 6 Sep 2006 04:58:45 -0000 1.98 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java 6 Sep 2006 16:11:08 -0000 @@ -498,9 +498,13 @@ int[] toSkip = null; if (iMethods != null) { total = initialTotal = iMethods.length; + boolean keepBridgeMethods = sourceLevel < ClassFileConstants.JDK1_5 + && this.environment.globalOptions.complianceLevel >= ClassFileConstants.JDK1_5; for (int i = total; --i >= 0;) { IBinaryMethod method = iMethods[i]; if ((method.getModifiers() & ClassFileConstants.AccSynthetic) != 0) { + if (keepBridgeMethods && (method.getModifiers() & ClassFileConstants.AccBridge) != 0) + continue; // want to see bridge methods as real methods // discard synthetics methods if (toSkip == null) toSkip = new int[iMethods.length]; toSkip[i] = -1; Index: compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java,v retrieving revision 1.282 diff -u -r1.282 Scope.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 17 Jul 2006 10:30:08 -0000 1.282 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 6 Sep 2006 16:11:08 -0000 @@ -759,8 +759,9 @@ CompilationUnitScope unitScope = compilationUnitScope(); unitScope.recordTypeReferences(argumentTypes); MethodBinding exactMethod = receiverType.getExactMethod(selector, argumentTypes, unitScope); - if (exactMethod != null && exactMethod.typeVariables == Binding.NO_TYPE_VARIABLES) { + if (exactMethod != null && exactMethod.typeVariables == Binding.NO_TYPE_VARIABLES && !exactMethod.isBridge()) { // must find both methods for this case: void foo() {} and N foo() { return null; } + // or find an inherited method when the exact match is to a bridge method unitScope.recordTypeReferences(exactMethod.thrownExceptions); // special treatment for Object.getClass() in 1.5 mode (substitute parameterized return type) if (receiverType.isInterface() || exactMethod.canBeSeenBy(receiverType, invocationSite, this)) { @@ -1086,6 +1087,8 @@ continue nextMethod; // keep inherited substituted methods to detect anonymous errors if (matchingMethod.hasSubstitutedParameters() && !currentMethod.original().areParametersEqual(matchingMethod.original())) continue nextMethod; // keep inherited substituted methods to detect anonymous errors + if (matchingMethod.isBridge() && !currentMethod.isBridge()) + continue nextMethod; // keep inherited methods to find concrete method over a bridge method } currentLength--; currentMethods[i] = null; @@ -3226,6 +3229,10 @@ continue nextVisible; if (!isAcceptableMethod(tiebreakMethod, acceptable)) continue nextVisible; + // pick a concrete method over a bridge method when parameters are equal since the return type of the concrete method is more specific + if (current.isBridge() && !next.isBridge()) + if (tiebreakMethod.areParametersEqual(acceptable)) + continue nextVisible; // skip current so acceptable wins over this bridge method } moreSpecific[i] = current; count++; #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java,v retrieving revision 1.59 diff -u -r1.59 LookupTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java 17 Jul 2006 10:29:53 -0000 1.59 +++ src/org/eclipse/jdt/core/tests/compiler/regression/LookupTest.java 6 Sep 2006 16:11:09 -0000 @@ -2325,6 +2325,59 @@ options, null); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=139099 +public void test068a() { + Map options = this.getCompilerOptions(); + CompilerOptions compOptions = new CompilerOptions(options); + if (compOptions.complianceLevel < ClassFileConstants.JDK1_5) return; + + this.runConformTest( + new String[] { + "X1.java", + "public class X1 { X1 foo() { return null; } }\n" + + "class X2 extends X1 { X2 foo() { return null; } }\n" + + "class Y { public X2 foo() { return null; } }\n" + + "interface I { X1 foo(); }\n" + + "class Z extends Y implements I {}", + }, + ""); + this.runConformTest( + new String[] { + "Test.java",//=================== + "public class Test {\n" + + " public static void main(String[] args) {\n" + + " X1 x = new X2().foo();\n" + + " X2 xx = new X2().foo();\n" + + " X1 z = new Z().foo();\n" + + " X2 zz = new Z().foo();\n" + + " }\n" + + "}", // =================, + }, + "", + null, + false, + null); + + options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4); + this.runConformTest( + new String[] { + "Test14.java",//=================== + "public class Test14 {\n" + + " public static void main(String[] args) {\n" + + " X1 x = new X2().foo();\n" + + " X2 xx = new X2().foo();\n" + + " X1 z = new Z().foo();\n" + + " X2 zz = new Z().foo();\n" + + " }\n" + + "}", // =================, + }, + "", + null, + false, + null, + options, + null); +} //https://bugs.eclipse.org/bugs/show_bug.cgi?id=139099 - variation public void test069() { this.runConformTest(