Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java,v retrieving revision 1.94 diff -u -r1.94 ParameterizedTypeBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java 12 Apr 2007 10:32:24 -0000 1.94 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java 24 May 2007 19:30:57 -0000 @@ -399,6 +399,7 @@ */ public MethodBinding getExactConstructor(TypeBinding[] argumentTypes) { int argCount = argumentTypes.length; + MethodBinding match = null; if ((tagBits & TagBits.AreMethodsComplete) != 0) { // have resolved all arg types & return type of the methods long range; @@ -409,8 +410,9 @@ TypeBinding[] toMatch = method.parameters; for (int iarg = 0; iarg < argCount; iarg++) if (toMatch[iarg] != argumentTypes[iarg]) - continue nextMethod; - return method; + continue nextMethod;; + if (match != null) return null; // collision case + match = method; } } } @@ -422,12 +424,13 @@ if (toMatch.length == argCount) { for (int p = 0; p < argCount; p++) if (toMatch[p] != argumentTypes[p]) - continue nextMethod; - return method; + continue nextMethod;; + if (match != null) return null; // collision case + match = method; } } } - return null; + return match; } /** Index: src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java,v retrieving revision 1.44 diff -u -r1.44 AmbiguousMethodTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java 24 May 2007 14:29:36 -0000 1.44 +++ src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java 24 May 2007 19:30:57 -0000 @@ -2039,4 +2039,35 @@ }, ""); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=188960 +public void test059() { + this.runNegativeTest( + new String[] { + "X.java", + "class X {\n" + + " X() {}\n" + + " X(String s) {}\n" + + " X(T t) {}\n" + + "}\n" + + "class NoErrorSubclass extends X {}\n" + + "class StringOnlySubClass extends X {\n" + + " StringOnlySubClass(String s) { super(s); }\n" + + "}\n" + + "class Test {\n" + + " Object s = new X(\"xyz\");\n" + + "}" + }, + "----------\n" + + "1. ERROR in X.java (at line 8)\n" + + " StringOnlySubClass(String s) { super(s); }\n" + + " ^^^^^^^^^\n" + + "The constructor X(String) is ambiguous\n" + + "----------\n" + + "2. ERROR in X.java (at line 11)\n" + + " Object s = new X(\"xyz\");\n" + + " ^^^^^^^^^^^^^^^^^^^^\n" + + "The constructor X(String) is ambiguous\n" + + "----------\n" + ); +} }