View | Details | Raw Unified | Return to bug 188960
Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java (-5 / +8 lines)
Lines 399-404 Link Here
399
	 */
399
	 */
400
	public MethodBinding getExactConstructor(TypeBinding[] argumentTypes) {
400
	public MethodBinding getExactConstructor(TypeBinding[] argumentTypes) {
401
		int argCount = argumentTypes.length;
401
		int argCount = argumentTypes.length;
402
		MethodBinding match = null;
402
403
403
		if ((tagBits & TagBits.AreMethodsComplete) != 0) { // have resolved all arg types & return type of the methods
404
		if ((tagBits & TagBits.AreMethodsComplete) != 0) { // have resolved all arg types & return type of the methods
404
			long range;
405
			long range;
Lines 409-416 Link Here
409
						TypeBinding[] toMatch = method.parameters;
410
						TypeBinding[] toMatch = method.parameters;
410
						for (int iarg = 0; iarg < argCount; iarg++)
411
						for (int iarg = 0; iarg < argCount; iarg++)
411
							if (toMatch[iarg] != argumentTypes[iarg])
412
							if (toMatch[iarg] != argumentTypes[iarg])
412
								continue nextMethod;
413
								continue nextMethod;;
413
						return method;
414
						if (match != null) return null; // collision case
415
						match = method;
414
					}
416
					}
415
				}
417
				}
416
			}
418
			}
Lines 422-433 Link Here
422
				if (toMatch.length == argCount) {
424
				if (toMatch.length == argCount) {
423
					for (int p = 0; p < argCount; p++)
425
					for (int p = 0; p < argCount; p++)
424
						if (toMatch[p] != argumentTypes[p])
426
						if (toMatch[p] != argumentTypes[p])
425
							continue nextMethod;
427
							continue nextMethod;;
426
						return method;
428
						if (match != null) return null; // collision case
429
						match = method;
427
				}
430
				}
428
			}
431
			}
429
		}
432
		}
430
		return null;
433
		return match;
431
	}
434
	}
432
435
433
	/**
436
	/**
(-)src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java (+31 lines)
Lines 2039-2042 Link Here
2039
		},
2039
		},
2040
		"");
2040
		"");
2041
}
2041
}
2042
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=188960
2043
public void test059() {
2044
	this.runNegativeTest(
2045
		new String[] {
2046
			"X.java",
2047
			"class X<T> {\n" + 
2048
			"	X() {}\n" + 
2049
			"	X(String s) {}\n" + 
2050
			"	X(T t) {}\n" + 
2051
			"}\n" +
2052
			"class NoErrorSubclass extends X<String> {}\n" +
2053
			"class StringOnlySubClass extends X<String> {\n" +
2054
			"	StringOnlySubClass(String s) { super(s); }\n" +
2055
			"}\n" +
2056
			"class Test {\n" +
2057
			"	Object s = new X<String>(\"xyz\");\n" +
2058
			"}"
2059
		},
2060
		"----------\n" + 
2061
		"1. ERROR in X.java (at line 8)\n" + 
2062
		"	StringOnlySubClass(String s) { super(s); }\n" + 
2063
		"	                               ^^^^^^^^^\n" + 
2064
		"The constructor X<String>(String) is ambiguous\n" + 
2065
		"----------\n" + 
2066
		"2. ERROR in X.java (at line 11)\n" + 
2067
		"	Object s = new X<String>(\"xyz\");\n" + 
2068
		"	           ^^^^^^^^^^^^^^^^^^^^\n" + 
2069
		"The constructor X<String>(String) is ambiguous\n" + 
2070
		"----------\n"
2071
	);
2072
}
2042
}
2073
}

Return to bug 188960