View | Details | Raw Unified | Return to bug 317719 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java (-2 / +10 lines)
Lines 196-202 Link Here
196
			final MethodBinding thisMethod = current[i];
196
			final MethodBinding thisMethod = current[i];
197
			if (thisMethod.areParameterErasuresEqual(bridge) && thisMethod.returnType.erasure() == bridge.returnType.erasure()) {
197
			if (thisMethod.areParameterErasuresEqual(bridge) && thisMethod.returnType.erasure() == bridge.returnType.erasure()) {
198
				// use inherited method for problem reporting.
198
				// use inherited method for problem reporting.
199
				problemReporter(thisMethod).methodNameClash(thisMethod, inheritedMethod.declaringClass.isRawType() ? inheritedMethod : inheritedMethod.original());
199
				problemReporter(thisMethod).methodNameClash(thisMethod, inheritedMethod.declaringClass.isRawType() ? inheritedMethod : inheritedMethod.original(), ProblemSeverities.Error);
200
				return;	
200
				return;	
201
			}
201
			}
202
		}
202
		}
Lines 725-730 Link Here
725
	MethodBinding original = methodToCheck.original(); // can be the same as inherited
725
	MethodBinding original = methodToCheck.original(); // can be the same as inherited
726
	if (!current.areParameterErasuresEqual(original))
726
	if (!current.areParameterErasuresEqual(original))
727
		return false;
727
		return false;
728
	int severity = ProblemSeverities.Error;
729
	if (this.environment.globalOptions.complianceLevel == ClassFileConstants.JDK1_6) {
730
		// for 1.6 return types also need to be checked
731
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=317719
732
		if (current.returnType.erasure() != original.returnType.erasure())
733
			severity = ProblemSeverities.Warning;
734
	}
728
	if (!treatAsSynthetic) {
735
	if (!treatAsSynthetic) {
729
		// For a user method, see if current class overrides the inherited method. If it does,
736
		// For a user method, see if current class overrides the inherited method. If it does,
730
		// then any grievance we may have ought to be against the current class's method and
737
		// then any grievance we may have ought to be against the current class's method and
Lines 748-754 Link Here
748
	if (!current.areParameterErasuresEqual(original))
755
	if (!current.areParameterErasuresEqual(original))
749
		return false;
756
		return false;
750
	original = inherited.original();  // For error reporting use, inherited.original()
757
	original = inherited.original();  // For error reporting use, inherited.original()
751
	problemReporter(current).methodNameClash(current, inherited.declaringClass.isRawType() ? inherited : original);
758
	problemReporter(current).methodNameClash(current, inherited.declaringClass.isRawType() ? inherited : original, severity);
759
	if (severity == ProblemSeverities.Warning) return false;
752
	return true;
760
	return true;
753
}
761
}
754
public boolean doesMethodOverride(MethodBinding method, MethodBinding inheritedMethod) {
762
public boolean doesMethodOverride(MethodBinding method, MethodBinding inheritedMethod) {
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java (-5 / +90 lines)
Lines 26-31 Link Here
26
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
26
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
27
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
27
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
28
import org.eclipse.jdt.internal.compiler.impl.Constant;
28
import org.eclipse.jdt.internal.compiler.impl.Constant;
29
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
29
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable;
30
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable;
30
import org.eclipse.jdt.internal.compiler.util.Util;
31
import org.eclipse.jdt.internal.compiler.util.Util;
31
32
Lines 1183-1188 Link Here
1183
1184
1184
		// find & report collision cases
1185
		// find & report collision cases
1185
		boolean complyTo15 = this.scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5;
1186
		boolean complyTo15 = this.scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5;
1187
		boolean compliance16 = this.scope.compilerOptions().complianceLevel == ClassFileConstants.JDK1_6;
1188
		int severity = ProblemSeverities.Error;
1186
		for (int i = 0, length = this.methods.length; i < length; i++) {
1189
		for (int i = 0, length = this.methods.length; i < length; i++) {
1187
			MethodBinding method = resolvedMethods[i];
1190
			MethodBinding method = resolvedMethods[i];
1188
			if (method == null)
1191
			if (method == null)
Lines 1195-1206 Link Here
1195
					continue nextSibling;
1198
					continue nextSibling;
1196
				if (!CharOperation.equals(selector, method2.selector))
1199
				if (!CharOperation.equals(selector, method2.selector))
1197
					break nextSibling; // methods with same selector are contiguous
1200
					break nextSibling; // methods with same selector are contiguous
1201
				if (complyTo15 && method.returnType != null && method2.returnType != null) {
1202
						// 8.4.2, for collision to be detected between m1 and m2:
1203
						// signature(m1) == signature(m2) i.e. same arity, same type parameter count, can be substituted
1204
						// signature(m1) == erasure(signature(m2)) or erasure(signature(m1)) == signature(m2)
1205
						TypeBinding[] params1 = method.parameters;
1206
						TypeBinding[] params2 = method2.parameters;
1207
						int pLength = params1.length;
1208
						if (pLength != params2.length)
1209
							continue nextSibling;
1210
					
1211
						TypeVariableBinding[] vars = method.typeVariables;
1212
						TypeVariableBinding[] vars2 = method2.typeVariables;
1213
						boolean equalTypeVars = vars == vars2;
1214
						MethodBinding subMethod = method2;
1215
						if (!equalTypeVars) {
1216
							MethodBinding temp = method.computeSubstitutedMethod(method2, this.scope.environment());
1217
							if (temp != null) {
1218
								equalTypeVars = true;
1219
								subMethod = temp;
1220
							}
1221
						}
1222
						boolean equalParams = method.areParametersEqual(subMethod);
1223
						if (equalParams && equalTypeVars) {
1224
							// duplicates regardless of return types
1225
						} else if (equalParams || method.areParameterErasuresEqual(method2)){
1226
							// with fix for http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
1227
							// we now ignore return types in 1.7 when detecting duplicates, just as we did before 1.5 
1228
							// name clash for sure if not duplicates, report as duplicates
1229
							// Only in 1.6, we have to make sure even return types are same
1230
							if (compliance16) {
1231
								if (method.returnType.erasure() != subMethod.returnType.erasure()) {
1232
									severity = ProblemSeverities.Warning;
1233
								}
1234
								// else return types also equal. All conditions satisfied
1235
								// to give error in 1.6 compliance as well.
1236
							}
1237
						} else if (!equalTypeVars && vars != Binding.NO_TYPE_VARIABLES && vars2 != Binding.NO_TYPE_VARIABLES) {
1238
							// type variables are different so we can distinguish between methods
1239
							continue nextSibling;
1240
						} else if (pLength > 0) {
1241
							// check to see if the erasure of either method is equal to the other
1242
							int index = pLength;
1243
							for (; --index >= 0;) {
1244
								if (params1[index] != params2[index].erasure())
1245
									break;
1246
								if (params1[index] == params2[index]) {
1247
									TypeBinding type = params1[index].leafComponentType();
1248
									if (type instanceof SourceTypeBinding && type.typeVariables() != Binding.NO_TYPE_VARIABLES) {
1249
										index = pLength; // handle comparing identical source types like X<T>... its erasure is itself BUT we need to answer false
1250
										break;
1251
									}
1252
								}
1253
							}
1254
							if (index >= 0 && index < pLength) {
1255
								for (index = pLength; --index >= 0;)
1256
									if (params1[index].erasure() != params2[index])
1257
										break;
1258
							}
1259
							if (index >= 0)
1260
								continue nextSibling;
1261
						}
1262
					} else if (!method.areParametersEqual(method2)) { // prior to 1.5, parameter identity meant a collision case
1263
						continue nextSibling;
1264
					}
1198
1265
1199
				if (complyTo15 ? !method.areParameterErasuresEqual(method2) : !method.areParametersEqual(method2))
1266
//				if (complyTo15) {
1200
					continue nextSibling; // otherwise duplicates / name clash
1267
//					if (method.areParameterErasuresEqual(method2)) {
1268
//						// we now ignore return types in 1.7 when detecting duplicates, just as we did before 1.5 
1269
//						// Only in 1.6, we have to make sure even return types are different
1270
//						// https://bugs.eclipse.org/bugs/show_bug.cgi?id=317719
1271
//						if (compliance16 && method.returnType != null && method2.returnType != null) {
1272
//							if (method.returnType.erasure() != method2.returnType.erasure()) {
1273
//								severity = ProblemSeverities.Warning;
1274
//							}
1275
//							// else return types also equal. All conditions satisfied
1276
//							// to give error in 1.6 compliance as well.
1277
//						}
1278
//					} else {
1279
//						continue nextSibling;
1280
//					}
1281
//				} else if (!method.areParametersEqual(method2)) {
1282
//					// prior to 1.5, parameters identical meant a collision case
1283
//					continue nextSibling;
1284
//				}
1285
				// otherwise duplicates / name clash
1201
				boolean isEnumSpecialMethod = isEnum() && (CharOperation.equals(selector,TypeConstants.VALUEOF) || CharOperation.equals(selector,TypeConstants.VALUES));
1286
				boolean isEnumSpecialMethod = isEnum() && (CharOperation.equals(selector,TypeConstants.VALUEOF) || CharOperation.equals(selector,TypeConstants.VALUES));
1202
				// report duplicate
1287
				// report duplicate
1203
				boolean removeMethod2 = true;
1288
				boolean removeMethod2 = (severity == ProblemSeverities.Error) ? true : false; // do not remove if in 1.6 and just a warning given
1204
				if (methodDecl == null) {
1289
				if (methodDecl == null) {
1205
					methodDecl = method.sourceMethod(); // cannot be retrieved after binding is lost & may still be null if method is special
1290
					methodDecl = method.sourceMethod(); // cannot be retrieved after binding is lost & may still be null if method is special
1206
					if (methodDecl != null && methodDecl.binding != null) { // ensure its a valid user defined method
1291
					if (methodDecl != null && methodDecl.binding != null) { // ensure its a valid user defined method
Lines 1210-1216 Link Here
1210
							// remove user defined methods & keep the synthetic
1295
							// remove user defined methods & keep the synthetic
1211
							removeMethod = true;
1296
							removeMethod = true;
1212
						} else {
1297
						} else {
1213
							this.scope.problemReporter().duplicateMethodInType(this, methodDecl, method.areParametersEqual(method2));
1298
							this.scope.problemReporter().duplicateMethodInType(this, methodDecl, method.areParametersEqual(method2), severity);
1214
						}
1299
						}
1215
						if (removeMethod) {
1300
						if (removeMethod) {
1216
							removeMethod2 = false;
1301
							removeMethod2 = false;
Lines 1229-1235 Link Here
1229
						this.scope.problemReporter().duplicateEnumSpecialMethod(this, method2Decl);
1314
						this.scope.problemReporter().duplicateEnumSpecialMethod(this, method2Decl);
1230
						removeMethod2 = true;
1315
						removeMethod2 = true;
1231
					} else {
1316
					} else {
1232
						this.scope.problemReporter().duplicateMethodInType(this, method2Decl, method.areParametersEqual(method2));
1317
						this.scope.problemReporter().duplicateMethodInType(this, method2Decl, method.areParametersEqual(method2), severity);
1233
					}
1318
					}
1234
					if (removeMethod2) {
1319
					if (removeMethod2) {
1235
						method2Decl.binding = null;
1320
						method2Decl.binding = null;
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (-2 / +5 lines)
Lines 1593-1599 Link Here
1593
		nodeSourceStart(local, location),
1593
		nodeSourceStart(local, location),
1594
		nodeSourceEnd(local, location));
1594
		nodeSourceEnd(local, location));
1595
}
1595
}
1596
public void duplicateMethodInType(SourceTypeBinding type, AbstractMethodDeclaration methodDecl, boolean equalParameters) {
1596
public void duplicateMethodInType(SourceTypeBinding type, AbstractMethodDeclaration methodDecl, boolean equalParameters, int severity) {
1597
    MethodBinding method = methodDecl.binding;
1597
    MethodBinding method = methodDecl.binding;
1598
    if (equalParameters) {
1598
    if (equalParameters) {
1599
		this.handle(
1599
		this.handle(
Lines 1606-1611 Link Here
1606
				new String(methodDecl.selector),
1606
				new String(methodDecl.selector),
1607
				new String(method.declaringClass.shortReadableName()),
1607
				new String(method.declaringClass.shortReadableName()),
1608
				typesAsString(method, true)},
1608
				typesAsString(method, true)},
1609
			severity,
1609
			methodDecl.sourceStart,
1610
			methodDecl.sourceStart,
1610
			methodDecl.sourceEnd);
1611
			methodDecl.sourceEnd);
1611
    } else {
1612
    } else {
Lines 1626-1631 Link Here
1626
				new String(method.declaringClass.shortReadableName()),
1627
				new String(method.declaringClass.shortReadableName()),
1627
				typesAsString(method, true),
1628
				typesAsString(method, true),
1628
				typesAsString(method, erasures, true) },
1629
				typesAsString(method, erasures, true) },
1630
			severity,
1629
			methodDecl.sourceStart,
1631
			methodDecl.sourceStart,
1630
			methodDecl.sourceEnd);
1632
			methodDecl.sourceEnd);
1631
    }
1633
    }
Lines 5091-5097 Link Here
5091
		method.sourceEnd);
5093
		method.sourceEnd);
5092
}
5094
}
5093
5095
5094
public void methodNameClash(MethodBinding currentMethod, MethodBinding inheritedMethod) {
5096
public void methodNameClash(MethodBinding currentMethod, MethodBinding inheritedMethod, int severity) {
5095
	this.handle(
5097
	this.handle(
5096
		IProblem.MethodNameClash,
5098
		IProblem.MethodNameClash,
5097
		new String[] {
5099
		new String[] {
Lines 5108-5113 Link Here
5108
			typesAsString(inheritedMethod, true),
5110
			typesAsString(inheritedMethod, true),
5109
			new String(inheritedMethod.declaringClass.shortReadableName()),
5111
			new String(inheritedMethod.declaringClass.shortReadableName()),
5110
		 },
5112
		 },
5113
		severity,
5111
		currentMethod.sourceStart(),
5114
		currentMethod.sourceStart(),
5112
		currentMethod.sourceEnd());
5115
		currentMethod.sourceEnd());
5113
}
5116
}
(-)Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java (-11 / +16 lines)
Lines 22-28 Link Here
22
22
23
public class NegativeTest extends AbstractRegressionTest {
23
public class NegativeTest extends AbstractRegressionTest {
24
static {
24
static {
25
//	TESTS_NUMBERS = new int[] { 275 };
25
//	TESTS_NUMBERS = new int[] { 92 };
26
}
26
}
27
public NegativeTest(String name) {
27
public NegativeTest(String name) {
28
	super(name);
28
	super(name);
Lines 3697-3712 Link Here
3697
			"  }\n" +
3697
			"  }\n" +
3698
			"}",
3698
			"}",
3699
		},
3699
		},
3700
		"----------\n" +
3700
		"----------\n" + 
3701
		"1. ERROR in p\\Toplevel12.java (at line 4)\n" +
3701
		"1. ERROR in p\\Toplevel12.java (at line 4)\n" + 
3702
		"	Object local(){\n" +
3702
		"	Object local(){\n" + 
3703
		"	       ^^^^^^^\n" +
3703
		"	       ^^^^^^^\n" + 
3704
		"Duplicate method local() in type Toplevel12\n" +
3704
		"Duplicate method local() in type Toplevel12\n" + 
3705
		"----------\n" +
3705
		"----------\n" + 
3706
		"2. ERROR in p\\Toplevel12.java (at line 17)\n" +
3706
		"2. ERROR in p\\Toplevel12.java (at line 15)\n" + 
3707
		"	void local(){\n" +
3707
		"	return new Package2.Sub();\n" + 
3708
		"	     ^^^^^^^\n" +
3708
		"	       ^^^^^^^^^^^^^^^^^^\n" + 
3709
		"Duplicate method local() in type Toplevel12\n" +
3709
		"No enclosing instance of type Package2 is accessible. Must qualify the allocation with an enclosing instance of type Package2 (e.g. x.new A() where x is an instance of Package2).\n" + 
3710
		"----------\n" + 
3711
		"3. ERROR in p\\Toplevel12.java (at line 17)\n" + 
3712
		"	void local(){\n" + 
3713
		"	     ^^^^^^^\n" + 
3714
		"Duplicate method local() in type Toplevel12\n" + 
3710
		"----------\n"
3715
		"----------\n"
3711
	);
3716
	);
3712
}
3717
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java (-213 / +497 lines)
Lines 12-17 Link Here
12
12
13
import java.util.Map;
13
import java.util.Map;
14
14
15
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
15
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
16
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
16
17
17
import junit.framework.*;
18
import junit.framework.*;
Lines 19-25 Link Here
19
public class AmbiguousMethodTest extends AbstractComparableTest {
20
public class AmbiguousMethodTest extends AbstractComparableTest {
20
21
21
	static {
22
	static {
22
//		TESTS_NAMES = new String [] { "test087" };
23
//		TESTS_NAMES = new String [] { "test010a" };
23
	}
24
	}
24
	public AmbiguousMethodTest(String name) {
25
	public AmbiguousMethodTest(String name) {
25
		super(name);
26
		super(name);
Lines 241-246 Link Here
241
	}
242
	}
242
	public void test005() {
243
	public void test005() {
243
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
244
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
245
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
246
				"----------\n" + 
247
				"1. WARNING in X.java (at line 2)\n" + 
248
				"	<S extends A> void foo() { }\n" + 
249
				"	                   ^^^^^\n" + 
250
				"Duplicate method foo() in type X\n" + 
251
				"----------\n" + 
252
				"2. WARNING in X.java (at line 3)\n" + 
253
				"	<N extends B> N foo() { return null; }\n" + 
254
				"	                ^^^^^\n" + 
255
				"Duplicate method foo() in type X\n" + 
256
				"----------\n" + 
257
				"3. ERROR in X.java (at line 5)\n" + 
258
				"	new X().foo();\n" + 
259
				"	        ^^^\n" + 
260
				"The method foo() is ambiguous for the type X\n" + 
261
				"----------\n":
262
					"----------\n" + 
263
					"1. ERROR in X.java (at line 2)\n" + 
264
					"	<S extends A> void foo() { }\n" + 
265
					"	                   ^^^^^\n" + 
266
					"Duplicate method foo() in type X\n" + 
267
					"----------\n" + 
268
					"2. ERROR in X.java (at line 3)\n" + 
269
					"	<N extends B> N foo() { return null; }\n" + 
270
					"	                ^^^^^\n" + 
271
					"Duplicate method foo() in type X\n" + 
272
					"----------\n";
244
		this.runNegativeTest(
273
		this.runNegativeTest(
245
			new String[] {
274
			new String[] {
246
				"X.java",
275
				"X.java",
Lines 254-271 Link Here
254
				"class A {}\n" +
283
				"class A {}\n" +
255
				"class B {}\n"
284
				"class B {}\n"
256
			},
285
			},
257
			"----------\n" + 
286
			expectedCompilerLog);
258
			"1. ERROR in X.java (at line 2)\n" + 
259
			"	<S extends A> void foo() { }\n" + 
260
			"	                   ^^^^^\n" + 
261
			"Duplicate method foo() in type X\n" + 
262
			"----------\n" + 
263
			"2. ERROR in X.java (at line 3)\n" + 
264
			"	<N extends B> N foo() { return null; }\n" + 
265
			"	                ^^^^^\n" + 
266
			"Duplicate method foo() in type X\n" + 
267
			"----------\n"
268
		);
269
/* javac 7
287
/* javac 7
270
X.java:3: name clash: <N>foo() and <S>foo() have the same erasure
288
X.java:3: name clash: <N>foo() and <S>foo() have the same erasure
271
                 <N extends B> N foo() { return null; }
289
                 <N extends B> N foo() { return null; }
Lines 278-300 Link Here
278
	}
296
	}
279
	public void test006() {
297
	public void test006() {
280
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
298
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
281
		this.runNegativeTest(
299
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
282
			new String[] {
300
		"----------\n" + 
283
				"X.java",
301
		"1. ERROR in X.java (at line 3)\n" + 
284
				"public class X<T> {\n" +
302
		"	new Y<Object>().foo(\"X\");\n" + 
285
				"   void test() {\n" +
303
		"	                ^^^\n" + 
286
				"   	new Y<Object>().foo(\"X\");\n" +
304
		"The method foo(Object) is ambiguous for the type Y<Object>\n" + 
287
				"   	new Y<Object>().foo2(\"X\");\n" +
305
		"----------\n" + 
288
				"   }\n" +
306
		"2. ERROR in X.java (at line 4)\n" + 
289
				"	<U1> U1 foo(U1 t) {return null;}\n" +
307
		"	new Y<Object>().foo2(\"X\");\n" + 
290
				"	<U2> U2 foo2(U2 t) {return null;}\n" +
308
		"	                ^^^^\n" + 
291
				"}\n" +
309
		"The method foo2(Object) is ambiguous for the type Y<Object>\n" + 
292
				"class Y<T2> extends X<T2> {\n" +
310
		"----------\n" + 
293
				"	void foo(T2 t) {}\n" +
311
		"3. WARNING in X.java (at line 10)\n" + 
294
				"	<U3> void foo2(T2 t) {}\n" +
312
		"	void foo(T2 t) {}\n" + 
295
				"}\n"
313
		"	     ^^^^^^^^^\n" + 
296
			},
314
		"Name clash: The method foo(T2) of type Y<T2> has the same erasure as foo(U1) of type X<T> but does not override it\n" + 
297
			"----------\n" +
315
		"----------\n" + 
316
		"4. WARNING in X.java (at line 11)\n" + 
317
		"	<U3> void foo2(T2 t) {}\n" + 
318
		"	          ^^^^^^^^^^\n" + 
319
		"Name clash: The method foo2(T2) of type Y<T2> has the same erasure as foo2(U2) of type X<T> but does not override it\n" + 
320
		"----------\n":
321
			"----------\n" + 
298
			"1. ERROR in X.java (at line 3)\n" + 
322
			"1. ERROR in X.java (at line 3)\n" + 
299
			"	new Y<Object>().foo(\"X\");\n" + 
323
			"	new Y<Object>().foo(\"X\");\n" + 
300
			"	                ^^^\n" + 
324
			"	                ^^^\n" + 
Lines 314-320 Link Here
314
			"	<U3> void foo2(T2 t) {}\n" + 
338
			"	<U3> void foo2(T2 t) {}\n" + 
315
			"	          ^^^^^^^^^^\n" + 
339
			"	          ^^^^^^^^^^\n" + 
316
			"Name clash: The method foo2(T2) of type Y<T2> has the same erasure as foo2(U2) of type X<T> but does not override it\n" + 
340
			"Name clash: The method foo2(T2) of type Y<T2> has the same erasure as foo2(U2) of type X<T> but does not override it\n" + 
317
			"----------\n"
341
			"----------\n";
342
		this.runNegativeTest(
343
			new String[] {
344
				"X.java",
345
				"public class X<T> {\n" +
346
				"   void test() {\n" +
347
				"   	new Y<Object>().foo(\"X\");\n" +
348
				"   	new Y<Object>().foo2(\"X\");\n" +
349
				"   }\n" +
350
				"	<U1> U1 foo(U1 t) {return null;}\n" +
351
				"	<U2> U2 foo2(U2 t) {return null;}\n" +
352
				"}\n" +
353
				"class Y<T2> extends X<T2> {\n" +
354
				"	void foo(T2 t) {}\n" +
355
				"	<U3> void foo2(T2 t) {}\n" +
356
				"}\n"
357
			},
358
			expectedCompilerLog
318
		);
359
		);
319
/* javac 7
360
/* javac 7
320
X.java:3: reference to foo is ambiguous, both method <U1>foo(U1) in X and method
361
X.java:3: reference to foo is ambiguous, both method <U1>foo(U1) in X and method
Lines 541-546 Link Here
541
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106090
582
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106090
542
	public void test011a() {
583
	public void test011a() {
543
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
584
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
585
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
586
		"----------\n" + 
587
		"1. WARNING in Combined.java (at line 2)\n" + 
588
		"	<T extends Comparable<T>> void pickOne(T value) throws ExOne {}\n" + 
589
		"	                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
590
		"Method pickOne(T) has the same erasure pickOne(Comparable<T>) as another method in type Combined<A,B>\n" + 
591
		"----------\n" + 
592
		"2. WARNING in Combined.java (at line 3)\n" + 
593
		"	<T> T pickOne(Comparable<T> value) throws ExTwo { return null;}\n" + 
594
		"	      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
595
		"Method pickOne(Comparable<T>) has the same erasure pickOne(Comparable<T>) as another method in type Combined<A,B>\n" + 
596
		"----------\n":
597
			"----------\n" + 
598
			"1. ERROR in Combined.java (at line 2)\n" + 
599
			"	<T extends Comparable<T>> void pickOne(T value) throws ExOne {}\n" + 
600
			"	                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
601
			"Method pickOne(T) has the same erasure pickOne(Comparable<T>) as another method in type Combined<A,B>\n" + 
602
			"----------\n" + 
603
			"2. ERROR in Combined.java (at line 3)\n" + 
604
			"	<T> T pickOne(Comparable<T> value) throws ExTwo { return null;}\n" + 
605
			"	      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
606
			"Method pickOne(Comparable<T>) has the same erasure pickOne(Comparable<T>) as another method in type Combined<A,B>\n" + 
607
			"----------\n";
544
		this.runNegativeTest(
608
		this.runNegativeTest(
545
			new String[] {
609
			new String[] {
546
				"Combined.java",
610
				"Combined.java",
Lines 555-571 Link Here
555
				"class ExOne extends Exception {static final long serialVersionUID = 1;}\n" +
619
				"class ExOne extends Exception {static final long serialVersionUID = 1;}\n" +
556
				"class ExTwo extends Exception {static final long serialVersionUID = 2;}"
620
				"class ExTwo extends Exception {static final long serialVersionUID = 2;}"
557
			},
621
			},
558
			"----------\n" + 
622
			expectedCompilerLog
559
			"1. ERROR in Combined.java (at line 2)\n" + 
560
			"	<T extends Comparable<T>> void pickOne(T value) throws ExOne {}\n" + 
561
			"	                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
562
			"Method pickOne(T) has the same erasure pickOne(Comparable<T>) as another method in type Combined<A,B>\n" + 
563
			"----------\n" + 
564
			"2. ERROR in Combined.java (at line 3)\n" + 
565
			"	<T> T pickOne(Comparable<T> value) throws ExTwo { return null;}\n" + 
566
			"	      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
567
			"Method pickOne(Comparable<T>) has the same erasure pickOne(Comparable<T>) as another method in type Combined<A,B>\n" + 
568
			"----------\n"
569
		);
623
		);
570
/* javac 7
624
/* javac 7
571
X.java:3: name clash: <T#1>pickOne(Comparable<T#1>) and <T#2>pickOne(T#2) have the same erasure
625
X.java:3: name clash: <T#1>pickOne(Comparable<T#1>) and <T#2>pickOne(T#2) have the same erasure
Lines 580-596 Link Here
580
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106090
634
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106090
581
	public void test011b() {
635
	public void test011b() {
582
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
636
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
583
		this.runNegativeTest(
637
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
584
			new String[] {
638
		"----------\n" + 
585
				"Test1.java",
639
		"1. WARNING in Test1.java (at line 2)\n" + 
586
				"public class Test1<AA, BB> {\n" +
640
		"	<T extends Comparable<T>> void pickOne(T value) throws ExOne {}\n" + 
587
				"	<T extends Comparable<T>> void pickOne(T value) throws ExOne {}\n" +
641
		"	                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
588
				"	<T> T pickOne(Comparable<T> value) throws ExTwo { return null;}\n" +
642
		"Method pickOne(T) has the same erasure pickOne(Comparable<T>) as another method in type Test1<AA,BB>\n" + 
589
				"	void pickOne2(Test1<Integer,Integer> c) throws ExOne { c.pickOne((Comparable) \"test\"); }\n" +
643
		"----------\n" + 
590
				"}\n" +
644
		"2. WARNING in Test1.java (at line 3)\n" + 
591
				"class ExOne extends Exception {static final long serialVersionUID = 1;}\n" +
645
		"	<T> T pickOne(Comparable<T> value) throws ExTwo { return null;}\n" + 
592
				"class ExTwo extends Exception {static final long serialVersionUID = 2;}"
646
		"	      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
593
			},
647
		"Method pickOne(Comparable<T>) has the same erasure pickOne(Comparable<T>) as another method in type Test1<AA,BB>\n" + 
648
		"----------\n" + 
649
		"3. WARNING in Test1.java (at line 4)\n" + 
650
		"	void pickOne2(Test1<Integer,Integer> c) throws ExOne { c.pickOne((Comparable) \"test\"); }\n" + 
651
		"	                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
652
		"Type safety: Unchecked invocation pickOne(Comparable) of the generic method pickOne(T) of type Test1<Integer,Integer>\n" + 
653
		"----------\n" + 
654
		"4. WARNING in Test1.java (at line 4)\n" + 
655
		"	void pickOne2(Test1<Integer,Integer> c) throws ExOne { c.pickOne((Comparable) \"test\"); }\n" + 
656
		"	                                                                  ^^^^^^^^^^\n" + 
657
		"Comparable is a raw type. References to generic type Comparable<T> should be parameterized\n" + 
658
		"----------\n":
594
			"----------\n" + 
659
			"----------\n" + 
595
			"1. ERROR in Test1.java (at line 2)\n" + 
660
			"1. ERROR in Test1.java (at line 2)\n" + 
596
			"	<T extends Comparable<T>> void pickOne(T value) throws ExOne {}\n" + 
661
			"	<T extends Comparable<T>> void pickOne(T value) throws ExOne {}\n" + 
Lines 611-617 Link Here
611
			"	void pickOne2(Test1<Integer,Integer> c) throws ExOne { c.pickOne((Comparable) \"test\"); }\n" + 
676
			"	void pickOne2(Test1<Integer,Integer> c) throws ExOne { c.pickOne((Comparable) \"test\"); }\n" + 
612
			"	                                                                  ^^^^^^^^^^\n" + 
677
			"	                                                                  ^^^^^^^^^^\n" + 
613
			"Comparable is a raw type. References to generic type Comparable<T> should be parameterized\n" + 
678
			"Comparable is a raw type. References to generic type Comparable<T> should be parameterized\n" + 
614
			"----------\n"
679
			"----------\n";
680
		this.runNegativeTest(
681
			new String[] {
682
				"Test1.java",
683
				"public class Test1<AA, BB> {\n" +
684
				"	<T extends Comparable<T>> void pickOne(T value) throws ExOne {}\n" +
685
				"	<T> T pickOne(Comparable<T> value) throws ExTwo { return null;}\n" +
686
				"	void pickOne2(Test1<Integer,Integer> c) throws ExOne { c.pickOne((Comparable) \"test\"); }\n" +
687
				"}\n" +
688
				"class ExOne extends Exception {static final long serialVersionUID = 1;}\n" +
689
				"class ExTwo extends Exception {static final long serialVersionUID = 2;}"
690
			},
691
			expectedCompilerLog
615
		);
692
		);
616
/* javac 7
693
/* javac 7
617
X.java:3: name clash: <T#1>pickOne(Comparable<T#1>) and <T#2>pickOne(T#2) have the same erasure
694
X.java:3: name clash: <T#1>pickOne(Comparable<T#1>) and <T#2>pickOne(T#2) have the same erasure
Lines 1570-1597 Link Here
1570
	// variant: having both methods in the same class should not change anything
1647
	// variant: having both methods in the same class should not change anything
1571
	public void test021() {
1648
	public void test021() {
1572
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
1649
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
1573
		this.runNegativeTest(
1650
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
1574
			new String[] {
1651
		"----------\n" + 
1575
				"Y.java",
1652
		"1. WARNING in Y.java (at line 3)\n" + 
1576
				"class X<T extends Object> {\n" +
1653
		"	public class Y<V extends String> extends X<V> {\n" + 
1577
				"}\n" +
1654
		"	                         ^^^^^^\n" + 
1578
				"public class Y<V extends String> extends X<V> {\n" +
1655
		"The type parameter V should not be bounded by the final type String. Final types cannot be further extended\n" + 
1579
				"  public static <W extends String> Y<W> make(Class<W> clazz) {\n" +
1656
		"----------\n" + 
1580
				"    System.out.print(true);\n" +
1657
		"2. WARNING in Y.java (at line 4)\n" + 
1581
				"    return new Y<W>();\n" +
1658
		"	public static <W extends String> Y<W> make(Class<W> clazz) {\n" + 
1582
				"  }\n" +
1659
		"	                         ^^^^^^\n" + 
1583
				"  public static <U extends Object> X<U> make(Class<U> clazz) {\n" +
1660
		"The type parameter W should not be bounded by the final type String. Final types cannot be further extended\n" + 
1584
				"    System.out.print(false);\n" +
1661
		"----------\n" + 
1585
				"    return new X<U>();\n" +
1662
		"3. WARNING in Y.java (at line 4)\n" + 
1586
				"  }\n" +
1663
		"	public static <W extends String> Y<W> make(Class<W> clazz) {\n" + 
1587
				"  public static void main(String[] args) throws Exception {\n" +
1664
		"	                                      ^^^^^^^^^^^^^^^^^^^^\n" + 
1588
				"    Y.make(getClazz());\n" +
1665
		"Method make(Class<W>) has the same erasure make(Class<T>) as another method in type Y<V>\n" + 
1589
				"  }\n" +
1666
		"----------\n" + 
1590
				"  public static Class getClazz() {\n" +
1667
		"4. WARNING in Y.java (at line 8)\n" + 
1591
				"    return String.class;\n" +
1668
		"	public static <U extends Object> X<U> make(Class<U> clazz) {\n" + 
1592
				"  }\n" +
1669
		"	                                      ^^^^^^^^^^^^^^^^^^^^\n" + 
1593
				"}"
1670
		"Method make(Class<U>) has the same erasure make(Class<T>) as another method in type Y<V>\n" + 
1594
			},
1671
		"----------\n" + 
1672
		"5. WARNING in Y.java (at line 13)\n" + 
1673
		"	Y.make(getClazz());\n" + 
1674
		"	^^^^^^^^^^^^^^^^^^\n" + 
1675
		"Type safety: Unchecked invocation make(Class) of the generic method make(Class<W>) of type Y\n" + 
1676
		"----------\n" + 
1677
		"6. WARNING in Y.java (at line 13)\n" + 
1678
		"	Y.make(getClazz());\n" + 
1679
		"	       ^^^^^^^^^^\n" + 
1680
		"Type safety: The expression of type Class needs unchecked conversion to conform to Class<String>\n" + 
1681
		"----------\n" + 
1682
		"7. WARNING in Y.java (at line 15)\n" + 
1683
		"	public static Class getClazz() {\n" + 
1684
		"	              ^^^^^\n" + 
1685
		"Class is a raw type. References to generic type Class<T> should be parameterized\n" + 
1686
		"----------\n":
1595
			"----------\n" + 
1687
			"----------\n" + 
1596
			"1. WARNING in Y.java (at line 3)\n" + 
1688
			"1. WARNING in Y.java (at line 3)\n" + 
1597
			"	public class Y<V extends String> extends X<V> {\n" + 
1689
			"	public class Y<V extends String> extends X<V> {\n" + 
Lines 1627-1633 Link Here
1627
			"	public static Class getClazz() {\n" + 
1719
			"	public static Class getClazz() {\n" + 
1628
			"	              ^^^^^\n" + 
1720
			"	              ^^^^^\n" + 
1629
			"Class is a raw type. References to generic type Class<T> should be parameterized\n" + 
1721
			"Class is a raw type. References to generic type Class<T> should be parameterized\n" + 
1630
			"----------\n"
1722
			"----------\n";
1723
		this.runNegativeTest(
1724
			new String[] {
1725
				"Y.java",
1726
				"class X<T extends Object> {\n" +
1727
				"}\n" +
1728
				"public class Y<V extends String> extends X<V> {\n" +
1729
				"  public static <W extends String> Y<W> make(Class<W> clazz) {\n" +
1730
				"    System.out.print(true);\n" +
1731
				"    return new Y<W>();\n" +
1732
				"  }\n" +
1733
				"  public static <U extends Object> X<U> make(Class<U> clazz) {\n" +
1734
				"    System.out.print(false);\n" +
1735
				"    return new X<U>();\n" +
1736
				"  }\n" +
1737
				"  public static void main(String[] args) throws Exception {\n" +
1738
				"    Y.make(getClazz());\n" +
1739
				"  }\n" +
1740
				"  public static Class getClazz() {\n" +
1741
				"    return String.class;\n" +
1742
				"  }\n" +
1743
				"}"
1744
			},
1745
			expectedCompilerLog
1631
		);
1746
		);
1632
/* javac 7
1747
/* javac 7
1633
X.java:8: name clash: <U>make(Class<U>) and <W>make(Class<W>) have the same erasure
1748
X.java:8: name clash: <U>make(Class<U>) and <W>make(Class<W>) have the same erasure
Lines 1659-1687 Link Here
1659
	// variant: using instances triggers raw methods, which are ambiguous
1774
	// variant: using instances triggers raw methods, which are ambiguous
1660
	public void test022() {
1775
	public void test022() {
1661
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
1776
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
1662
		this.runNegativeTest(
1777
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
1663
			new String[] {
1778
		"----------\n" + 
1664
				"X.java",
1779
		"1. WARNING in X.java (at line 3)\n" + 
1665
				"public class X<T extends Object> {\n" +
1780
		"	class Y<V extends String> extends X<V> {\n" + 
1666
				"}\n" +
1781
		"	                  ^^^^^^\n" + 
1667
				"class Y<V extends String> extends X<V> {\n" +
1782
		"The type parameter V should not be bounded by the final type String. Final types cannot be further extended\n" + 
1668
				"  public <W extends String> Y<W> make(Class<W> clazz) {\n" +
1783
		"----------\n" + 
1669
				"    return new Y<W>();\n" +
1784
		"2. WARNING in X.java (at line 4)\n" + 
1670
				"  }\n" +
1785
		"	public <W extends String> Y<W> make(Class<W> clazz) {\n" + 
1671
				"  public <U extends Object> X<U> make(Class<U> clazz) {\n" +
1786
		"	                  ^^^^^^\n" + 
1672
				"    return new X<U>();\n" +
1787
		"The type parameter W should not be bounded by the final type String. Final types cannot be further extended\n" + 
1673
				"  }\n" +
1788
		"----------\n" + 
1674
				"  public static void main(String[] args) throws Exception {\n" +
1789
		"3. WARNING in X.java (at line 4)\n" + 
1675
				"    Y y = new Y();\n" +
1790
		"	public <W extends String> Y<W> make(Class<W> clazz) {\n" + 
1676
				"    y.make(String.class);\n" +
1791
		"	                               ^^^^^^^^^^^^^^^^^^^^\n" + 
1677
				"    y.make(getClazz());\n" +
1792
		"Method make(Class<W>) has the same erasure make(Class<T>) as another method in type Y<V>\n" + 
1678
				"    y.make(getClazz().newInstance().getClass());\n" +
1793
		"----------\n" + 
1679
				"  }\n" +
1794
		"4. WARNING in X.java (at line 7)\n" + 
1680
				"  public static Class getClazz() {\n" +
1795
		"	public <U extends Object> X<U> make(Class<U> clazz) {\n" + 
1681
				"    return String.class;\n" +
1796
		"	                               ^^^^^^^^^^^^^^^^^^^^\n" + 
1682
				"  }\n" +
1797
		"Method make(Class<U>) has the same erasure make(Class<T>) as another method in type Y<V>\n" + 
1683
				"}"
1798
		"----------\n" + 
1684
			},
1799
		"5. WARNING in X.java (at line 11)\n" + 
1800
		"	Y y = new Y();\n" + 
1801
		"	^\n" + 
1802
		"Y is a raw type. References to generic type Y<V> should be parameterized\n" + 
1803
		"----------\n" + 
1804
		"6. WARNING in X.java (at line 11)\n" + 
1805
		"	Y y = new Y();\n" + 
1806
		"	          ^\n" + 
1807
		"Y is a raw type. References to generic type Y<V> should be parameterized\n" + 
1808
		"----------\n" + 
1809
		"7. ERROR in X.java (at line 12)\n" + 
1810
		"	y.make(String.class);\n" + 
1811
		"	  ^^^^\n" + 
1812
		"The method make(Class) is ambiguous for the type Y\n" + 
1813
		"----------\n" + 
1814
		"8. ERROR in X.java (at line 13)\n" + 
1815
		"	y.make(getClazz());\n" + 
1816
		"	  ^^^^\n" + 
1817
		"The method make(Class) is ambiguous for the type Y\n" + 
1818
		"----------\n" + 
1819
		"9. ERROR in X.java (at line 14)\n" + 
1820
		"	y.make(getClazz().newInstance().getClass());\n" + 
1821
		"	  ^^^^\n" + 
1822
		"The method make(Class) is ambiguous for the type Y\n" + 
1823
		"----------\n" + 
1824
		"10. WARNING in X.java (at line 16)\n" + 
1825
		"	public static Class getClazz() {\n" + 
1826
		"	              ^^^^^\n" + 
1827
		"Class is a raw type. References to generic type Class<T> should be parameterized\n" + 
1828
		"----------\n":
1685
			"----------\n" + 
1829
			"----------\n" + 
1686
			"1. WARNING in X.java (at line 3)\n" + 
1830
			"1. WARNING in X.java (at line 3)\n" + 
1687
			"	class Y<V extends String> extends X<V> {\n" + 
1831
			"	class Y<V extends String> extends X<V> {\n" + 
Lines 1732-1738 Link Here
1732
			"	public static Class getClazz() {\n" + 
1876
			"	public static Class getClazz() {\n" + 
1733
			"	              ^^^^^\n" + 
1877
			"	              ^^^^^\n" + 
1734
			"Class is a raw type. References to generic type Class<T> should be parameterized\n" + 
1878
			"Class is a raw type. References to generic type Class<T> should be parameterized\n" + 
1735
			"----------\n"
1879
			"----------\n";
1880
		this.runNegativeTest(
1881
			new String[] {
1882
				"X.java",
1883
				"public class X<T extends Object> {\n" +
1884
				"}\n" +
1885
				"class Y<V extends String> extends X<V> {\n" +
1886
				"  public <W extends String> Y<W> make(Class<W> clazz) {\n" +
1887
				"    return new Y<W>();\n" +
1888
				"  }\n" +
1889
				"  public <U extends Object> X<U> make(Class<U> clazz) {\n" +
1890
				"    return new X<U>();\n" +
1891
				"  }\n" +
1892
				"  public static void main(String[] args) throws Exception {\n" +
1893
				"    Y y = new Y();\n" +
1894
				"    y.make(String.class);\n" +
1895
				"    y.make(getClazz());\n" +
1896
				"    y.make(getClazz().newInstance().getClass());\n" +
1897
				"  }\n" +
1898
				"  public static Class getClazz() {\n" +
1899
				"    return String.class;\n" +
1900
				"  }\n" +
1901
				"}"
1902
			},
1903
			expectedCompilerLog
1736
		);
1904
		);
1737
/* javac 7
1905
/* javac 7
1738
X.java:7: name clash: <U>make(Class<U>) and <W>make(Class<W>) have the same erasure
1906
X.java:7: name clash: <U>make(Class<U>) and <W>make(Class<W>) have the same erasure
Lines 1884-1889 Link Here
1884
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=162026
2052
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=162026
1885
// variant
2053
// variant
1886
public void test027() {
2054
public void test027() {
2055
	String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
2056
			"----------\n" + 
2057
			"1. WARNING in J.java (at line 2)\n" + 
2058
			"	<T extends Number> T foo(final Number p);\n" + 
2059
			"	                     ^^^^^^^^^^^^^^^^^^^\n" + 
2060
			"Duplicate method foo(Number) in type J\n" + 
2061
			"----------\n" + 
2062
			"2. WARNING in J.java (at line 3)\n" + 
2063
			"	Float foo(final Number p);\n" + 
2064
			"	      ^^^^^^^^^^^^^^^^^^^\n" + 
2065
			"Duplicate method foo(Number) in type J\n" + 
2066
			"----------\n":
2067
				"----------\n" +
2068
				"1. ERROR in J.java (at line 2)\n" +
2069
				"	<T extends Number> T foo(final Number p);\n" +
2070
				"	                     ^^^^^^^^^^^^^^^^^^^\n" +
2071
				"Duplicate method foo(Number) in type J\n" +
2072
				"----------\n" +
2073
				"2. ERROR in J.java (at line 3)\n" +
2074
				"	Float foo(final Number p);\n" +
2075
				"	      ^^^^^^^^^^^^^^^^^^^\n" +
2076
				"Duplicate method foo(Number) in type J\n" +
2077
				"----------\n";
1887
	this.runNegativeTest(
2078
	this.runNegativeTest(
1888
		new String[] {
2079
		new String[] {
1889
			"J.java",
2080
			"J.java",
Lines 1892-1908 Link Here
1892
			"  Float foo(final Number p);\n" +
2083
			"  Float foo(final Number p);\n" +
1893
			"}",
2084
			"}",
1894
		},
2085
		},
1895
		"----------\n" +
2086
		expectedCompilerLog);
1896
		"1. ERROR in J.java (at line 2)\n" +
1897
		"	<T extends Number> T foo(final Number p);\n" +
1898
		"	                     ^^^^^^^^^^^^^^^^^^^\n" +
1899
		"Duplicate method foo(Number) in type J\n" +
1900
		"----------\n" +
1901
		"2. ERROR in J.java (at line 3)\n" +
1902
		"	Float foo(final Number p);\n" +
1903
		"	      ^^^^^^^^^^^^^^^^^^^\n" +
1904
		"Duplicate method foo(Number) in type J\n" +
1905
		"----------\n");
1906
}
2087
}
1907
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=162065
2088
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=162065
1908
public void test028() {
2089
public void test028() {
Lines 3274-3279 Link Here
3274
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=268837
3455
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=268837
3275
// See that this test case exhibits the bug 345947
3456
// See that this test case exhibits the bug 345947
3276
public void test076() {
3457
public void test076() {
3458
	String output = (this.complianceLevel == ClassFileConstants.JDK1_6)?
3459
			"----------\n" + 
3460
			"1. WARNING in X.java (at line 8)\n" + 
3461
			"	<U> J<String> b();\n" + 
3462
			"	              ^^^\n" + 
3463
			"Name clash: The method b() of type J<E> has the same erasure as b() of type I<E> but does not override it\n" + 
3464
			"----------\n" + 
3465
			"2. ERROR in X.java (at line 15)\n" + 
3466
			"	J<Integer> b = ints.a();\n" + 
3467
			"	               ^^^^^^^^\n" + 
3468
			"Type mismatch: cannot convert from J<String> to J<Integer>\n" + 
3469
			"----------\n" + 
3470
			"3. ERROR in X.java (at line 16)\n" + 
3471
			"	J<Object> c = ints.a();\n" + 
3472
			"	              ^^^^^^^^\n" + 
3473
			"Type mismatch: cannot convert from J<String> to J<Object>\n" + 
3474
			"----------\n" + 
3475
			"4. WARNING in X.java (at line 17)\n" + 
3476
			"	J d = ints.a();\n" + 
3477
			"	^\n" + 
3478
			"J is a raw type. References to generic type J<E> should be parameterized\n" + 
3479
			"----------\n" + 
3480
			"5. ERROR in X.java (at line 19)\n" + 
3481
			"	I<Integer> f = ints.a();\n" + 
3482
			"	               ^^^^^^^^\n" + 
3483
			"Type mismatch: cannot convert from J<String> to I<Integer>\n" + 
3484
			"----------\n" + 
3485
			"6. ERROR in X.java (at line 20)\n" + 
3486
			"	I<Object> g = ints.a();\n" + 
3487
			"	              ^^^^^^^^\n" + 
3488
			"Type mismatch: cannot convert from J<String> to I<Object>\n" + 
3489
			"----------\n" + 
3490
			"7. WARNING in X.java (at line 21)\n" + 
3491
			"	I h = ints.a();\n" + 
3492
			"	^\n" + 
3493
			"I is a raw type. References to generic type I<E> should be parameterized\n" + 
3494
			"----------\n" + 
3495
			"8. ERROR in X.java (at line 24)\n" + 
3496
			"	ints.b();\n" + 
3497
			"	     ^\n" + 
3498
			"The method b() is ambiguous for the type J<Integer>\n" + 
3499
			"----------\n" + 
3500
			"9. ERROR in X.java (at line 25)\n" + 
3501
			"	J<String> a = ints.b();\n" + 
3502
			"	                   ^\n" + 
3503
			"The method b() is ambiguous for the type J<Integer>\n" + 
3504
			"----------\n" + 
3505
			"10. ERROR in X.java (at line 26)\n" + 
3506
			"	J<Integer> b = ints.b();\n" + 
3507
			"	                    ^\n" + 
3508
			"The method b() is ambiguous for the type J<Integer>\n" + 
3509
			"----------\n" + 
3510
			"11. ERROR in X.java (at line 27)\n" + 
3511
			"	J<Object> c = ints.b();\n" + 
3512
			"	                   ^\n" + 
3513
			"The method b() is ambiguous for the type J<Integer>\n" + 
3514
			"----------\n" + 
3515
			"12. WARNING in X.java (at line 28)\n" + 
3516
			"	J d = ints.b();\n" + 
3517
			"	^\n" + 
3518
			"J is a raw type. References to generic type J<E> should be parameterized\n" + 
3519
			"----------\n" + 
3520
			"13. ERROR in X.java (at line 28)\n" + 
3521
			"	J d = ints.b();\n" + 
3522
			"	           ^\n" + 
3523
			"The method b() is ambiguous for the type J<Integer>\n" + 
3524
			"----------\n" + 
3525
			"14. ERROR in X.java (at line 29)\n" + 
3526
			"	I<String> e = ints.b();\n" + 
3527
			"	                   ^\n" + 
3528
			"The method b() is ambiguous for the type J<Integer>\n" + 
3529
			"----------\n" + 
3530
			"15. ERROR in X.java (at line 30)\n" + 
3531
			"	I<Integer> f = ints.b();\n" + 
3532
			"	                    ^\n" + 
3533
			"The method b() is ambiguous for the type J<Integer>\n" + 
3534
			"----------\n" + 
3535
			"16. ERROR in X.java (at line 31)\n" + 
3536
			"	I<Object> g = ints.b();\n" + 
3537
			"	                   ^\n" + 
3538
			"The method b() is ambiguous for the type J<Integer>\n" + 
3539
			"----------\n" + 
3540
			"17. WARNING in X.java (at line 32)\n" + 
3541
			"	I h = ints.b();\n" + 
3542
			"	^\n" + 
3543
			"I is a raw type. References to generic type I<E> should be parameterized\n" + 
3544
			"----------\n" + 
3545
			"18. ERROR in X.java (at line 32)\n" + 
3546
			"	I h = ints.b();\n" + 
3547
			"	           ^\n" + 
3548
			"The method b() is ambiguous for the type J<Integer>\n" + 
3549
			"----------\n" + 
3550
			"19. WARNING in X.java (at line 39)\n" + 
3551
			"	J d = ints.c();\n" + 
3552
			"	^\n" + 
3553
			"J is a raw type. References to generic type J<E> should be parameterized\n" + 
3554
			"----------\n" + 
3555
			"20. WARNING in X.java (at line 43)\n" + 
3556
			"	I h = ints.c();\n" + 
3557
			"	^\n" + 
3558
			"I is a raw type. References to generic type I<E> should be parameterized\n" + 
3559
			"----------\n":
3560
				"----------\n" + 
3561
				"1. ERROR in X.java (at line 8)\n" + 
3562
				"	<U> J<String> b();\n" + 
3563
				"	              ^^^\n" + 
3564
				"Name clash: The method b() of type J<E> has the same erasure as b() of type I<E> but does not override it\n" + 
3565
				"----------\n" + 
3566
				"2. ERROR in X.java (at line 15)\n" + 
3567
				"	J<Integer> b = ints.a();\n" + 
3568
				"	               ^^^^^^^^\n" + 
3569
				"Type mismatch: cannot convert from J<String> to J<Integer>\n" + 
3570
				"----------\n" + 
3571
				"3. ERROR in X.java (at line 16)\n" + 
3572
				"	J<Object> c = ints.a();\n" + 
3573
				"	              ^^^^^^^^\n" + 
3574
				"Type mismatch: cannot convert from J<String> to J<Object>\n" + 
3575
				"----------\n" + 
3576
				"4. WARNING in X.java (at line 17)\n" + 
3577
				"	J d = ints.a();\n" + 
3578
				"	^\n" + 
3579
				"J is a raw type. References to generic type J<E> should be parameterized\n" + 
3580
				"----------\n" + 
3581
				"5. ERROR in X.java (at line 19)\n" + 
3582
				"	I<Integer> f = ints.a();\n" + 
3583
				"	               ^^^^^^^^\n" + 
3584
				"Type mismatch: cannot convert from J<String> to I<Integer>\n" + 
3585
				"----------\n" + 
3586
				"6. ERROR in X.java (at line 20)\n" + 
3587
				"	I<Object> g = ints.a();\n" + 
3588
				"	              ^^^^^^^^\n" + 
3589
				"Type mismatch: cannot convert from J<String> to I<Object>\n" + 
3590
				"----------\n" + 
3591
				"7. WARNING in X.java (at line 21)\n" + 
3592
				"	I h = ints.a();\n" + 
3593
				"	^\n" + 
3594
				"I is a raw type. References to generic type I<E> should be parameterized\n" + 
3595
				"----------\n" + 
3596
				"8. ERROR in X.java (at line 24)\n" + 
3597
				"	ints.b();\n" + 
3598
				"	     ^\n" + 
3599
				"The method b() is ambiguous for the type J<Integer>\n" + 
3600
				"----------\n" + 
3601
				"9. ERROR in X.java (at line 25)\n" + 
3602
				"	J<String> a = ints.b();\n" + 
3603
				"	                   ^\n" + 
3604
				"The method b() is ambiguous for the type J<Integer>\n" + 
3605
				"----------\n" + 
3606
				"10. ERROR in X.java (at line 26)\n" + 
3607
				"	J<Integer> b = ints.b();\n" + 
3608
				"	                    ^\n" + 
3609
				"The method b() is ambiguous for the type J<Integer>\n" + 
3610
				"----------\n" + 
3611
				"11. ERROR in X.java (at line 27)\n" + 
3612
				"	J<Object> c = ints.b();\n" + 
3613
				"	                   ^\n" + 
3614
				"The method b() is ambiguous for the type J<Integer>\n" + 
3615
				"----------\n" + 
3616
				"12. WARNING in X.java (at line 28)\n" + 
3617
				"	J d = ints.b();\n" + 
3618
				"	^\n" + 
3619
				"J is a raw type. References to generic type J<E> should be parameterized\n" + 
3620
				"----------\n" + 
3621
				"13. ERROR in X.java (at line 28)\n" + 
3622
				"	J d = ints.b();\n" + 
3623
				"	           ^\n" + 
3624
				"The method b() is ambiguous for the type J<Integer>\n" + 
3625
				"----------\n" + 
3626
				"14. ERROR in X.java (at line 29)\n" + 
3627
				"	I<String> e = ints.b();\n" + 
3628
				"	                   ^\n" + 
3629
				"The method b() is ambiguous for the type J<Integer>\n" + 
3630
				"----------\n" + 
3631
				"15. ERROR in X.java (at line 30)\n" + 
3632
				"	I<Integer> f = ints.b();\n" + 
3633
				"	                    ^\n" + 
3634
				"The method b() is ambiguous for the type J<Integer>\n" + 
3635
				"----------\n" + 
3636
				"16. ERROR in X.java (at line 31)\n" + 
3637
				"	I<Object> g = ints.b();\n" + 
3638
				"	                   ^\n" + 
3639
				"The method b() is ambiguous for the type J<Integer>\n" + 
3640
				"----------\n" + 
3641
				"17. WARNING in X.java (at line 32)\n" + 
3642
				"	I h = ints.b();\n" + 
3643
				"	^\n" + 
3644
				"I is a raw type. References to generic type I<E> should be parameterized\n" + 
3645
				"----------\n" + 
3646
				"18. ERROR in X.java (at line 32)\n" + 
3647
				"	I h = ints.b();\n" + 
3648
				"	           ^\n" + 
3649
				"The method b() is ambiguous for the type J<Integer>\n" + 
3650
				"----------\n" + 
3651
				"19. WARNING in X.java (at line 39)\n" + 
3652
				"	J d = ints.c();\n" + 
3653
				"	^\n" + 
3654
				"J is a raw type. References to generic type J<E> should be parameterized\n" + 
3655
				"----------\n" + 
3656
				"20. WARNING in X.java (at line 43)\n" + 
3657
				"	I h = ints.c();\n" + 
3658
				"	^\n" + 
3659
				"I is a raw type. References to generic type I<E> should be parameterized\n" + 
3660
				"----------\n";
3277
	this.runNegativeTest(
3661
	this.runNegativeTest(
3278
		new String[] {
3662
		new String[] {
3279
			"X.java",
3663
			"X.java",
Lines 3323-3429 Link Here
3323
			"	}\n" +
3707
			"	}\n" +
3324
			"}"
3708
			"}"
3325
		},
3709
		},
3326
		"----------\n" + 
3710
		output
3327
		"1. ERROR in X.java (at line 8)\n" + 
3328
		"	<U> J<String> b();\n" + 
3329
		"	              ^^^\n" + 
3330
		"Name clash: The method b() of type J<E> has the same erasure as b() of type I<E> but does not override it\n" + 
3331
		"----------\n" + 
3332
		"2. ERROR in X.java (at line 15)\n" + 
3333
		"	J<Integer> b = ints.a();\n" + 
3334
		"	               ^^^^^^^^\n" + 
3335
		"Type mismatch: cannot convert from J<String> to J<Integer>\n" + 
3336
		"----------\n" + 
3337
		"3. ERROR in X.java (at line 16)\n" + 
3338
		"	J<Object> c = ints.a();\n" + 
3339
		"	              ^^^^^^^^\n" + 
3340
		"Type mismatch: cannot convert from J<String> to J<Object>\n" + 
3341
		"----------\n" + 
3342
		"4. WARNING in X.java (at line 17)\n" + 
3343
		"	J d = ints.a();\n" + 
3344
		"	^\n" + 
3345
		"J is a raw type. References to generic type J<E> should be parameterized\n" + 
3346
		"----------\n" + 
3347
		"5. ERROR in X.java (at line 19)\n" + 
3348
		"	I<Integer> f = ints.a();\n" + 
3349
		"	               ^^^^^^^^\n" + 
3350
		"Type mismatch: cannot convert from J<String> to I<Integer>\n" + 
3351
		"----------\n" + 
3352
		"6. ERROR in X.java (at line 20)\n" + 
3353
		"	I<Object> g = ints.a();\n" + 
3354
		"	              ^^^^^^^^\n" + 
3355
		"Type mismatch: cannot convert from J<String> to I<Object>\n" + 
3356
		"----------\n" + 
3357
		"7. WARNING in X.java (at line 21)\n" + 
3358
		"	I h = ints.a();\n" + 
3359
		"	^\n" + 
3360
		"I is a raw type. References to generic type I<E> should be parameterized\n" + 
3361
		"----------\n" + 
3362
		"8. ERROR in X.java (at line 24)\n" + 
3363
		"	ints.b();\n" + 
3364
		"	     ^\n" + 
3365
		"The method b() is ambiguous for the type J<Integer>\n" + 
3366
		"----------\n" + 
3367
		"9. ERROR in X.java (at line 25)\n" + 
3368
		"	J<String> a = ints.b();\n" + 
3369
		"	                   ^\n" + 
3370
		"The method b() is ambiguous for the type J<Integer>\n" + 
3371
		"----------\n" + 
3372
		"10. ERROR in X.java (at line 26)\n" + 
3373
		"	J<Integer> b = ints.b();\n" + 
3374
		"	                    ^\n" + 
3375
		"The method b() is ambiguous for the type J<Integer>\n" + 
3376
		"----------\n" + 
3377
		"11. ERROR in X.java (at line 27)\n" + 
3378
		"	J<Object> c = ints.b();\n" + 
3379
		"	                   ^\n" + 
3380
		"The method b() is ambiguous for the type J<Integer>\n" + 
3381
		"----------\n" + 
3382
		"12. WARNING in X.java (at line 28)\n" + 
3383
		"	J d = ints.b();\n" + 
3384
		"	^\n" + 
3385
		"J is a raw type. References to generic type J<E> should be parameterized\n" + 
3386
		"----------\n" + 
3387
		"13. ERROR in X.java (at line 28)\n" + 
3388
		"	J d = ints.b();\n" + 
3389
		"	           ^\n" + 
3390
		"The method b() is ambiguous for the type J<Integer>\n" + 
3391
		"----------\n" + 
3392
		"14. ERROR in X.java (at line 29)\n" + 
3393
		"	I<String> e = ints.b();\n" + 
3394
		"	                   ^\n" + 
3395
		"The method b() is ambiguous for the type J<Integer>\n" + 
3396
		"----------\n" + 
3397
		"15. ERROR in X.java (at line 30)\n" + 
3398
		"	I<Integer> f = ints.b();\n" + 
3399
		"	                    ^\n" + 
3400
		"The method b() is ambiguous for the type J<Integer>\n" + 
3401
		"----------\n" + 
3402
		"16. ERROR in X.java (at line 31)\n" + 
3403
		"	I<Object> g = ints.b();\n" + 
3404
		"	                   ^\n" + 
3405
		"The method b() is ambiguous for the type J<Integer>\n" + 
3406
		"----------\n" + 
3407
		"17. WARNING in X.java (at line 32)\n" + 
3408
		"	I h = ints.b();\n" + 
3409
		"	^\n" + 
3410
		"I is a raw type. References to generic type I<E> should be parameterized\n" + 
3411
		"----------\n" + 
3412
		"18. ERROR in X.java (at line 32)\n" + 
3413
		"	I h = ints.b();\n" + 
3414
		"	           ^\n" + 
3415
		"The method b() is ambiguous for the type J<Integer>\n" + 
3416
		"----------\n" + 
3417
		"19. WARNING in X.java (at line 39)\n" + 
3418
		"	J d = ints.c();\n" + 
3419
		"	^\n" + 
3420
		"J is a raw type. References to generic type J<E> should be parameterized\n" + 
3421
		"----------\n" + 
3422
		"20. WARNING in X.java (at line 43)\n" + 
3423
		"	I h = ints.c();\n" + 
3424
		"	^\n" + 
3425
		"I is a raw type. References to generic type I<E> should be parameterized\n" + 
3426
		"----------\n"
3427
	);
3711
	);
3428
}
3712
}
3429
3713
(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java (-143 / +297 lines)
Lines 17666-17671 Link Here
17666
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=87956
17666
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=87956
17667
	public void test0561() {
17667
	public void test0561() {
17668
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
17668
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
17669
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
17670
				"----------\n" + 
17671
				"1. WARNING in X.java (at line 2)\n" + 
17672
				"	void foo(A<String> a) {}\n" + 
17673
				"	     ^^^^^^^^^^^^^^^^\n" + 
17674
				"Method foo(A<String>) has the same erasure foo(A<T>) as another method in type X\n" + 
17675
				"----------\n" + 
17676
				"2. WARNING in X.java (at line 3)\n" + 
17677
				"	Object foo(A<Integer> a) { return null; }\n" + 
17678
				"	       ^^^^^^^^^^^^^^^^^\n" + 
17679
				"Method foo(A<Integer>) has the same erasure foo(A<T>) as another method in type X\n" + 
17680
				"----------\n":
17681
					"----------\n" + 
17682
					"1. ERROR in X.java (at line 2)\n" + 
17683
					"	void foo(A<String> a) {}\n" + 
17684
					"	     ^^^^^^^^^^^^^^^^\n" + 
17685
					"Method foo(A<String>) has the same erasure foo(A<T>) as another method in type X\n" + 
17686
					"----------\n" + 
17687
					"2. ERROR in X.java (at line 3)\n" + 
17688
					"	Object foo(A<Integer> a) { return null; }\n" + 
17689
					"	       ^^^^^^^^^^^^^^^^^\n" + 
17690
					"Method foo(A<Integer>) has the same erasure foo(A<T>) as another method in type X\n" + 
17691
					"----------\n" + 
17692
					"3. ERROR in X.java (at line 4)\n" + 
17693
					"	void test(A<Integer> a) { foo(a); }\n" + 
17694
					"	                          ^^^\n" + 
17695
					"The method foo(A<String>) in the type X is not applicable for the arguments (A<Integer>)\n" + 
17696
					"----------\n";
17669
		this.runNegativeTest(
17697
		this.runNegativeTest(
17670
			new String[] {
17698
			new String[] {
17671
				"X.java",
17699
				"X.java",
Lines 17676-17697 Link Here
17676
				"}\n" +
17704
				"}\n" +
17677
				"class A<T> {}\n",
17705
				"class A<T> {}\n",
17678
			},
17706
			},
17679
			"----------\n" + 
17707
			expectedCompilerLog
17680
			"1. ERROR in X.java (at line 2)\n" + 
17681
			"	void foo(A<String> a) {}\n" + 
17682
			"	     ^^^^^^^^^^^^^^^^\n" + 
17683
			"Method foo(A<String>) has the same erasure foo(A<T>) as another method in type X\n" + 
17684
			"----------\n" + 
17685
			"2. ERROR in X.java (at line 3)\n" + 
17686
			"	Object foo(A<Integer> a) { return null; }\n" + 
17687
			"	       ^^^^^^^^^^^^^^^^^\n" + 
17688
			"Method foo(A<Integer>) has the same erasure foo(A<T>) as another method in type X\n" + 
17689
			"----------\n" + 
17690
			"3. ERROR in X.java (at line 4)\n" + 
17691
			"	void test(A<Integer> a) { foo(a); }\n" + 
17692
			"	                          ^^^\n" + 
17693
			"The method foo(A<String>) in the type X is not applicable for the arguments (A<Integer>)\n" + 
17694
			"----------\n"
17695
		);
17708
		);
17696
/* javac 7
17709
/* javac 7
17697
X.java:3: name clash: foo(A<Integer>) and foo(A<String>) have the same erasure
17710
X.java:3: name clash: foo(A<Integer>) and foo(A<String>) have the same erasure
Lines 17704-17709 Link Here
17704
  found: A<Integer>
17717
  found: A<Integer>
17705
2 errors
17718
2 errors
17706
 */
17719
 */
17720
		String expectedCompilerLog2 = (this.complianceLevel == ClassFileConstants.JDK1_6)?
17721
				"----------\n" + 
17722
				"1. WARNING in X.java (at line 2)\n" + 
17723
				"	Number foo(A<String> a) { return null; }\n" + 
17724
				"	       ^^^^^^^^^^^^^^^^\n" + 
17725
				"Method foo(A<String>) has the same erasure foo(A<T>) as another method in type X\n" + 
17726
				"----------\n" + 
17727
				"2. WARNING in X.java (at line 3)\n" + 
17728
				"	Integer foo(A<Integer> a) { return null; }\n" + 
17729
				"	        ^^^^^^^^^^^^^^^^^\n" + 
17730
				"Method foo(A<Integer>) has the same erasure foo(A<T>) as another method in type X\n" + 
17731
				"----------\n":
17732
					"----------\n" + 
17733
					"1. ERROR in X.java (at line 2)\n" + 
17734
					"	Number foo(A<String> a) { return null; }\n" + 
17735
					"	       ^^^^^^^^^^^^^^^^\n" + 
17736
					"Method foo(A<String>) has the same erasure foo(A<T>) as another method in type X\n" + 
17737
					"----------\n" + 
17738
					"2. ERROR in X.java (at line 3)\n" + 
17739
					"	Integer foo(A<Integer> a) { return null; }\n" + 
17740
					"	        ^^^^^^^^^^^^^^^^^\n" + 
17741
					"Method foo(A<Integer>) has the same erasure foo(A<T>) as another method in type X\n" + 
17742
					"----------\n" + 
17743
					"3. ERROR in X.java (at line 4)\n" + 
17744
					"	void test(A<Integer> a) { foo(a); }\n" + 
17745
					"	                          ^^^\n" + 
17746
					"The method foo(A<String>) in the type X is not applicable for the arguments (A<Integer>)\n" + 
17747
					"----------\n";
17707
		this.runNegativeTest(
17748
		this.runNegativeTest(
17708
			new String[] {
17749
			new String[] {
17709
				"X.java",
17750
				"X.java",
Lines 17714-17735 Link Here
17714
				"}\n" +
17755
				"}\n" +
17715
				"class A<T> {}\n",
17756
				"class A<T> {}\n",
17716
			},
17757
			},
17717
			"----------\n" + 
17758
			expectedCompilerLog2
17718
			"1. ERROR in X.java (at line 2)\n" + 
17719
			"	Number foo(A<String> a) { return null; }\n" + 
17720
			"	       ^^^^^^^^^^^^^^^^\n" + 
17721
			"Method foo(A<String>) has the same erasure foo(A<T>) as another method in type X\n" + 
17722
			"----------\n" + 
17723
			"2. ERROR in X.java (at line 3)\n" + 
17724
			"	Integer foo(A<Integer> a) { return null; }\n" + 
17725
			"	        ^^^^^^^^^^^^^^^^^\n" + 
17726
			"Method foo(A<Integer>) has the same erasure foo(A<T>) as another method in type X\n" + 
17727
			"----------\n" + 
17728
			"3. ERROR in X.java (at line 4)\n" + 
17729
			"	void test(A<Integer> a) { foo(a); }\n" + 
17730
			"	                          ^^^\n" + 
17731
			"The method foo(A<String>) in the type X is not applicable for the arguments (A<Integer>)\n" + 
17732
			"----------\n"
17733
/* javac 7
17759
/* javac 7
17734
X.java:3: name clash: foo(A<Integer>) and foo(A<String>) have the same erasure
17760
X.java:3: name clash: foo(A<Integer>) and foo(A<String>) have the same erasure
17735
        Integer foo(A<Integer> a) { return null; }
17761
        Integer foo(A<Integer> a) { return null; }
Lines 18051-18056 Link Here
18051
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation
18077
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation
18052
	public void test0574() {
18078
	public void test0574() {
18053
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
18079
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
18080
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
18081
				"----------\n" + 
18082
				"1. WARNING in X.java (at line 6)\n" + 
18083
				"	<T extends Integer> T foo(Object o) {  return null; } // ok\n" + 
18084
				"	           ^^^^^^^\n" + 
18085
				"The type parameter T should not be bounded by the final type Integer. Final types cannot be further extended\n" + 
18086
				"----------\n" + 
18087
				"2. WARNING in X.java (at line 6)\n" + 
18088
				"	<T extends Integer> T foo(Object o) {  return null; } // ok\n" + 
18089
				"	                      ^^^^^^^^^^^^^\n" + 
18090
				"Duplicate method foo(Object) in type X.C2\n" + 
18091
				"----------\n" + 
18092
				"3. WARNING in X.java (at line 7)\n" + 
18093
				"	<T extends String> T foo(Object o) {  return null; } // ok\n" + 
18094
				"	           ^^^^^^\n" + 
18095
				"The type parameter T should not be bounded by the final type String. Final types cannot be further extended\n" + 
18096
				"----------\n" + 
18097
				"4. WARNING in X.java (at line 7)\n" + 
18098
				"	<T extends String> T foo(Object o) {  return null; } // ok\n" + 
18099
				"	                     ^^^^^^^^^^^^^\n" + 
18100
				"Duplicate method foo(Object) in type X.C2\n" + 
18101
				"----------\n" + 
18102
				"5. ERROR in X.java (at line 10)\n" + 
18103
				"	new X().new C2().foo((List<String>) null);\n" + 
18104
				"	                 ^^^\n" + 
18105
				"The method foo(Object) is ambiguous for the type X.C2\n" + 
18106
				"----------\n":
18107
					"----------\n" + 
18108
					"1. WARNING in X.java (at line 6)\n" + 
18109
					"	<T extends Integer> T foo(Object o) {  return null; } // ok\n" + 
18110
					"	           ^^^^^^^\n" + 
18111
					"The type parameter T should not be bounded by the final type Integer. Final types cannot be further extended\n" + 
18112
					"----------\n" + 
18113
					"2. ERROR in X.java (at line 6)\n" + 
18114
					"	<T extends Integer> T foo(Object o) {  return null; } // ok\n" + 
18115
					"	                      ^^^^^^^^^^^^^\n" + 
18116
					"Duplicate method foo(Object) in type X.C2\n" + 
18117
					"----------\n" + 
18118
					"3. WARNING in X.java (at line 7)\n" + 
18119
					"	<T extends String> T foo(Object o) {  return null; } // ok\n" + 
18120
					"	           ^^^^^^\n" + 
18121
					"The type parameter T should not be bounded by the final type String. Final types cannot be further extended\n" + 
18122
					"----------\n" + 
18123
					"4. ERROR in X.java (at line 7)\n" + 
18124
					"	<T extends String> T foo(Object o) {  return null; } // ok\n" + 
18125
					"	                     ^^^^^^^^^^^^^\n" + 
18126
					"Duplicate method foo(Object) in type X.C2\n" + 
18127
					"----------\n";
18054
		this.runNegativeTest(
18128
		this.runNegativeTest(
18055
			new String[] {
18129
			new String[] {
18056
				"X.java",
18130
				"X.java",
Lines 18067-18093 Link Here
18067
				"	}\n" +
18141
				"	}\n" +
18068
				"}\n"
18142
				"}\n"
18069
			},
18143
			},
18070
			"----------\n" + 
18144
			expectedCompilerLog
18071
			"1. WARNING in X.java (at line 6)\n" + 
18072
			"	<T extends Integer> T foo(Object o) {  return null; } // ok\n" + 
18073
			"	           ^^^^^^^\n" + 
18074
			"The type parameter T should not be bounded by the final type Integer. Final types cannot be further extended\n" + 
18075
			"----------\n" + 
18076
			"2. ERROR in X.java (at line 6)\n" + 
18077
			"	<T extends Integer> T foo(Object o) {  return null; } // ok\n" + 
18078
			"	                      ^^^^^^^^^^^^^\n" + 
18079
			"Duplicate method foo(Object) in type X.C2\n" + 
18080
			"----------\n" + 
18081
			"3. WARNING in X.java (at line 7)\n" + 
18082
			"	<T extends String> T foo(Object o) {  return null; } // ok\n" + 
18083
			"	           ^^^^^^\n" + 
18084
			"The type parameter T should not be bounded by the final type String. Final types cannot be further extended\n" + 
18085
			"----------\n" + 
18086
			"4. ERROR in X.java (at line 7)\n" + 
18087
			"	<T extends String> T foo(Object o) {  return null; } // ok\n" + 
18088
			"	                     ^^^^^^^^^^^^^\n" + 
18089
			"Duplicate method foo(Object) in type X.C2\n" + 
18090
			"----------\n"
18091
		);
18145
		);
18092
/*
18146
/*
18093
X.java:6: name clash: <T#1>foo(Object) and <T#2>foo(Object) have the same erasure
18147
X.java:6: name clash: <T#1>foo(Object) and <T#2>foo(Object) have the same erasure
Lines 22443-22448 Link Here
22443
}
22497
}
22444
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=97219
22498
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=97219
22445
public void test0706() {
22499
public void test0706() {
22500
	String outputExpectedBelow17 = (this.complianceLevel == ClassFileConstants.JDK1_6)?
22501
			"----------\n" + 
22502
			"1. WARNING in X.java (at line 9)\n" + 
22503
			"	class BB extends AA<CC> { <U> BB test() {return null;} }\n" + 
22504
			"	                                 ^^^^^^\n" + 
22505
			"Name clash: The method test() of type BB has the same erasure as test() of type AA<T> but does not override it\n" + 
22506
			"----------\n":
22507
				"----------\n" + 
22508
				"1. ERROR in X.java (at line 9)\n" + 
22509
				"	class BB extends AA<CC> { <U> BB test() {return null;} }\n" + 
22510
				"	                                 ^^^^^^\n" + 
22511
				"Name clash: The method test() of type BB has the same erasure as test() of type AA<T> but does not override it\n" + 
22512
				"----------\n";
22446
	this.runNegativeTest(
22513
	this.runNegativeTest(
22447
		new String[] {
22514
		new String[] {
22448
			"X.java",
22515
			"X.java",
Lines 22458-22469 Link Here
22458
			"class CC {}\n",
22525
			"class CC {}\n",
22459
		},
22526
		},
22460
		(this.complianceLevel < ClassFileConstants.JDK1_7)
22527
		(this.complianceLevel < ClassFileConstants.JDK1_7)
22461
		? "----------\n" + 
22528
		? outputExpectedBelow17
22462
		"1. ERROR in X.java (at line 9)\n" + 
22463
		"	class BB extends AA<CC> { <U> BB test() {return null;} }\n" + 
22464
		"	                                 ^^^^^^\n" + 
22465
		"Name clash: The method test() of type BB has the same erasure as test() of type AA<T> but does not override it\n" + 
22466
		"----------\n"
22467
		: "----------\n" + 
22529
		: "----------\n" + 
22468
		"1. ERROR in X.java (at line 4)\n" + 
22530
		"1. ERROR in X.java (at line 4)\n" + 
22469
		"	bb.<Object>test();\n" + 
22531
		"	bb.<Object>test();\n" + 
Lines 22493-22498 Link Here
22493
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=97219
22555
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=97219
22494
public void test0706a() {
22556
public void test0706a() {
22495
	// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
22557
	// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
22558
	String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
22559
			"----------\n" + 
22560
			"1. ERROR in X.java (at line 4)\n" + 
22561
			"	AA<Object> res1 = bb.test();\n" + 
22562
			"	                     ^^^^\n" + 
22563
			"The method test() is ambiguous for the type BB\n" + 
22564
			"----------\n" + 
22565
			"2. WARNING in X.java (at line 5)\n" + 
22566
			"	AA res3 = bb.test();\n" + 
22567
			"	^^\n" + 
22568
			"AA is a raw type. References to generic type AA<T> should be parameterized\n" + 
22569
			"----------\n" + 
22570
			"3. ERROR in X.java (at line 5)\n" + 
22571
			"	AA res3 = bb.test();\n" + 
22572
			"	             ^^^^\n" + 
22573
			"The method test() is ambiguous for the type BB\n" + 
22574
			"----------\n" + 
22575
			"4. WARNING in X.java (at line 9)\n" + 
22576
			"	class BB extends AA<CC> { <U> BB test() {return null;} }\n" + 
22577
			"	                                 ^^^^^^\n" + 
22578
			"Name clash: The method test() of type BB has the same erasure as test() of type AA<T> but does not override it\n" + 
22579
			"----------\n":
22580
				"----------\n" + 
22581
				"1. ERROR in X.java (at line 4)\n" + 
22582
				"	AA<Object> res1 = bb.test();\n" + 
22583
				"	                     ^^^^\n" + 
22584
				"The method test() is ambiguous for the type BB\n" + 
22585
				"----------\n" + 
22586
				"2. WARNING in X.java (at line 5)\n" + 
22587
				"	AA res3 = bb.test();\n" + 
22588
				"	^^\n" + 
22589
				"AA is a raw type. References to generic type AA<T> should be parameterized\n" + 
22590
				"----------\n" + 
22591
				"3. ERROR in X.java (at line 5)\n" + 
22592
				"	AA res3 = bb.test();\n" + 
22593
				"	             ^^^^\n" + 
22594
				"The method test() is ambiguous for the type BB\n" + 
22595
				"----------\n" + 
22596
				"4. ERROR in X.java (at line 9)\n" + 
22597
				"	class BB extends AA<CC> { <U> BB test() {return null;} }\n" + 
22598
				"	                                 ^^^^^^\n" + 
22599
				"Name clash: The method test() of type BB has the same erasure as test() of type AA<T> but does not override it\n" + 
22600
				"----------\n";
22496
	this.runNegativeTest(
22601
	this.runNegativeTest(
22497
		new String[] {
22602
		new String[] {
22498
			"X.java",
22603
			"X.java",
Lines 22507-22533 Link Here
22507
			"class BB extends AA<CC> { <U> BB test() {return null;} }\n" +
22612
			"class BB extends AA<CC> { <U> BB test() {return null;} }\n" +
22508
			"class CC {}\n",
22613
			"class CC {}\n",
22509
		},
22614
		},
22510
		"----------\n" + 
22615
		expectedCompilerLog
22511
		"1. ERROR in X.java (at line 4)\n" + 
22512
		"	AA<Object> res1 = bb.test();\n" + 
22513
		"	                     ^^^^\n" + 
22514
		"The method test() is ambiguous for the type BB\n" + 
22515
		"----------\n" + 
22516
		"2. WARNING in X.java (at line 5)\n" + 
22517
		"	AA res3 = bb.test();\n" + 
22518
		"	^^\n" + 
22519
		"AA is a raw type. References to generic type AA<T> should be parameterized\n" + 
22520
		"----------\n" + 
22521
		"3. ERROR in X.java (at line 5)\n" + 
22522
		"	AA res3 = bb.test();\n" + 
22523
		"	             ^^^^\n" + 
22524
		"The method test() is ambiguous for the type BB\n" + 
22525
		"----------\n" + 
22526
		"4. ERROR in X.java (at line 9)\n" + 
22527
		"	class BB extends AA<CC> { <U> BB test() {return null;} }\n" + 
22528
		"	                                 ^^^^^^\n" + 
22529
		"Name clash: The method test() of type BB has the same erasure as test() of type AA<T> but does not override it\n" + 
22530
		"----------\n"
22531
	);
22616
	);
22532
/*
22617
/*
22533
X.java:4: reference to test is ambiguous, both method test() in AA and method <U>test() in BB match
22618
X.java:4: reference to test is ambiguous, both method test() in AA and method <U>test() in BB match
Lines 22551-22556 Link Here
22551
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=97219
22636
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=97219
22552
public void test0706b() {
22637
public void test0706b() {
22553
	// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
22638
	// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
22639
	String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
22640
			"----------\n" + 
22641
			"1. ERROR in X.java (at line 4)\n" + 
22642
			"	AA<CC> res = bb.test();\n" + 
22643
			"	                ^^^^\n" + 
22644
			"The method test() is ambiguous for the type BB\n" + 
22645
			"----------\n" + 
22646
			"2. ERROR in X.java (at line 5)\n" + 
22647
			"	BB res2 = bb.test();\n" + 
22648
			"	             ^^^^\n" + 
22649
			"The method test() is ambiguous for the type BB\n" + 
22650
			"----------\n" + 
22651
			"3. WARNING in X.java (at line 9)\n" + 
22652
			"	class BB extends AA<CC> { <U> BB test() {return null;} }\n" + 
22653
			"	                                 ^^^^^^\n" + 
22654
			"Name clash: The method test() of type BB has the same erasure as test() of type AA<T> but does not override it\n" + 
22655
			"----------\n":
22656
				"----------\n" + 
22657
				"1. ERROR in X.java (at line 4)\n" + 
22658
				"	AA<CC> res = bb.test();\n" + 
22659
				"	                ^^^^\n" + 
22660
				"The method test() is ambiguous for the type BB\n" + 
22661
				"----------\n" + 
22662
				"2. ERROR in X.java (at line 5)\n" + 
22663
				"	BB res2 = bb.test();\n" + 
22664
				"	             ^^^^\n" + 
22665
				"The method test() is ambiguous for the type BB\n" + 
22666
				"----------\n" + 
22667
				"3. ERROR in X.java (at line 9)\n" + 
22668
				"	class BB extends AA<CC> { <U> BB test() {return null;} }\n" + 
22669
				"	                                 ^^^^^^\n" + 
22670
				"Name clash: The method test() of type BB has the same erasure as test() of type AA<T> but does not override it\n" + 
22671
				"----------\n";
22554
	this.runNegativeTest(
22672
	this.runNegativeTest(
22555
		new String[] {
22673
		new String[] {
22556
			"X.java",
22674
			"X.java",
Lines 22565-22586 Link Here
22565
			"class BB extends AA<CC> { <U> BB test() {return null;} }\n" +
22683
			"class BB extends AA<CC> { <U> BB test() {return null;} }\n" +
22566
			"class CC {}\n",
22684
			"class CC {}\n",
22567
		},
22685
		},
22568
		"----------\n" + 
22686
		expectedCompilerLog
22569
		"1. ERROR in X.java (at line 4)\n" + 
22570
		"	AA<CC> res = bb.test();\n" + 
22571
		"	                ^^^^\n" + 
22572
		"The method test() is ambiguous for the type BB\n" + 
22573
		"----------\n" + 
22574
		"2. ERROR in X.java (at line 5)\n" + 
22575
		"	BB res2 = bb.test();\n" + 
22576
		"	             ^^^^\n" + 
22577
		"The method test() is ambiguous for the type BB\n" + 
22578
		"----------\n" + 
22579
		"3. ERROR in X.java (at line 9)\n" + 
22580
		"	class BB extends AA<CC> { <U> BB test() {return null;} }\n" + 
22581
		"	                                 ^^^^^^\n" + 
22582
		"Name clash: The method test() of type BB has the same erasure as test() of type AA<T> but does not override it\n" + 
22583
		"----------\n"
22584
	);
22687
	);
22585
/*
22688
/*
22586
X.java:4: reference to test is ambiguous, both method test() in AA and method <U>test() in BB match
22689
X.java:4: reference to test is ambiguous, both method test() in AA and method <U>test() in BB match
Lines 23778-23783 Link Here
23778
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=100007
23881
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=100007
23779
public void test0748() {
23882
public void test0748() {
23780
	// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
23883
	// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
23884
	String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
23885
			"----------\n" + 
23886
			"1. WARNING in X.java (at line 5)\n" + 
23887
			"	public byte[] create(Class<byte[]> cl) { return null; }\n" + 
23888
			"	              ^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
23889
			"Name clash: The method create(Class<byte[]>) of type X has the same erasure as create(Class<U>) of type Factory<T> but does not override it\n" + 
23890
			"----------\n":
23891
				"----------\n" + 
23892
				"1. ERROR in X.java (at line 5)\n" + 
23893
				"	public byte[] create(Class<byte[]> cl) { return null; }\n" + 
23894
				"	              ^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
23895
				"Name clash: The method create(Class<byte[]>) of type X has the same erasure as create(Class<U>) of type Factory<T> but does not override it\n" + 
23896
				"----------\n";
23781
	this.runNegativeTest(
23897
	this.runNegativeTest(
23782
		new String[] {
23898
		new String[] {
23783
			"X.java",
23899
			"X.java",
Lines 23788-23799 Link Here
23788
			"	public byte[] create(Class<byte[]> cl) { return null; }\n" +
23904
			"	public byte[] create(Class<byte[]> cl) { return null; }\n" +
23789
			"}\n",
23905
			"}\n",
23790
		},
23906
		},
23791
		"----------\n" + 
23907
		expectedCompilerLog
23792
		"1. ERROR in X.java (at line 5)\n" + 
23793
		"	public byte[] create(Class<byte[]> cl) { return null; }\n" + 
23794
		"	              ^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
23795
		"Name clash: The method create(Class<byte[]>) of type X has the same erasure as create(Class<U>) of type Factory<T> but does not override it\n" + 
23796
		"----------\n"
23797
	);
23908
	);
23798
// javac 7 reports the name clash when X subclasses another class or is a concrete type
23909
// javac 7 reports the name clash when X subclasses another class or is a concrete type
23799
}
23910
}
Lines 40374-40379 Link Here
40374
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=204534
40485
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=204534
40375
public void test1181() {
40486
public void test1181() {
40376
	// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
40487
	// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
40488
	String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
40489
			"----------\n" + 
40490
			"1. ERROR in X.java (at line 2)\n" + 
40491
			"	public static <S, T extends Comparable<S>, R extends S & T> R max(T arg1, S arg2) {\n" + 
40492
			"	                                                         ^\n" + 
40493
			"Cannot specify any additional bound T when first bound is a type parameter\n" + 
40494
			"----------\n" + 
40495
			"2. ERROR in X.java (at line 2)\n" + 
40496
			"	public static <S, T extends Comparable<S>, R extends S & T> R max(T arg1, S arg2) {\n" + 
40497
			"	                                                              ^^^^^^^^^^^^^^^^^^^\n" + 
40498
			"Method max(T, S) has the same erasure max(Comparable<T>, Object) as another method in type X\n" + 
40499
			"----------\n" + 
40500
			"3. WARNING in X.java (at line 3)\n" + 
40501
			"	return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + 
40502
			"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
40503
			"Type safety: Unchecked cast from Object to R\n" + 
40504
			"----------\n" + 
40505
			"4. ERROR in X.java (at line 5)\n" + 
40506
			"	public static <T extends Comparable<S>, S, R extends S & Comparable<S>> R max(T arg1, S arg2) {\n" + 
40507
			"	                                                         ^^^^^^^^^^\n" + 
40508
			"Cannot specify any additional bound Comparable<S> when first bound is a type parameter\n" + 
40509
			"----------\n" + 
40510
			"5. ERROR in X.java (at line 5)\n" + 
40511
			"	public static <T extends Comparable<S>, S, R extends S & Comparable<S>> R max(T arg1, S arg2) {\n" + 
40512
			"	                                                                          ^^^^^^^^^^^^^^^^^^^\n" + 
40513
			"Method max(T, S) has the same erasure max(Comparable<T>, Object) as another method in type X\n" + 
40514
			"----------\n" + 
40515
			"6. WARNING in X.java (at line 6)\n" + 
40516
			"	return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + 
40517
			"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
40518
			"Type safety: Unchecked cast from Object to R\n" + 
40519
			"----------\n" + 
40520
			"7. WARNING in X.java (at line 8)\n" + 
40521
			"	public static <T extends Comparable<S>, S, R extends Comparable<S>> R max(T arg1, S arg2) {\n" + 
40522
			"	                                                                      ^^^^^^^^^^^^^^^^^^^\n" + 
40523
			"Method max(T, S) has the same erasure max(Comparable<T>, Object) as another method in type X\n" + 
40524
			"----------\n" + 
40525
			"8. WARNING in X.java (at line 9)\n" + 
40526
			"	return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + 
40527
			"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
40528
			"Type safety: Unchecked cast from Object to R\n" + 
40529
			"----------\n":
40530
				"----------\n" + 
40531
				"1. ERROR in X.java (at line 2)\n" + 
40532
				"	public static <S, T extends Comparable<S>, R extends S & T> R max(T arg1, S arg2) {\n" + 
40533
				"	                                                         ^\n" + 
40534
				"Cannot specify any additional bound T when first bound is a type parameter\n" + 
40535
				"----------\n" + 
40536
				"2. ERROR in X.java (at line 2)\n" + 
40537
				"	public static <S, T extends Comparable<S>, R extends S & T> R max(T arg1, S arg2) {\n" + 
40538
				"	                                                              ^^^^^^^^^^^^^^^^^^^\n" + 
40539
				"Method max(T, S) has the same erasure max(Comparable<T>, Object) as another method in type X\n" + 
40540
				"----------\n" + 
40541
				"3. WARNING in X.java (at line 3)\n" + 
40542
				"	return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + 
40543
				"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
40544
				"Type safety: Unchecked cast from Object to R\n" + 
40545
				"----------\n" + 
40546
				"4. ERROR in X.java (at line 5)\n" + 
40547
				"	public static <T extends Comparable<S>, S, R extends S & Comparable<S>> R max(T arg1, S arg2) {\n" + 
40548
				"	                                                         ^^^^^^^^^^\n" + 
40549
				"Cannot specify any additional bound Comparable<S> when first bound is a type parameter\n" + 
40550
				"----------\n" + 
40551
				"5. ERROR in X.java (at line 5)\n" + 
40552
				"	public static <T extends Comparable<S>, S, R extends S & Comparable<S>> R max(T arg1, S arg2) {\n" + 
40553
				"	                                                                          ^^^^^^^^^^^^^^^^^^^\n" + 
40554
				"Method max(T, S) has the same erasure max(Comparable<T>, Object) as another method in type X\n" + 
40555
				"----------\n" + 
40556
				"6. WARNING in X.java (at line 6)\n" + 
40557
				"	return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + 
40558
				"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
40559
				"Type safety: Unchecked cast from Object to R\n" + 
40560
				"----------\n" + 
40561
				"7. ERROR in X.java (at line 8)\n" + 
40562
				"	public static <T extends Comparable<S>, S, R extends Comparable<S>> R max(T arg1, S arg2) {\n" + 
40563
				"	                                                                      ^^^^^^^^^^^^^^^^^^^\n" + 
40564
				"Method max(T, S) has the same erasure max(Comparable<T>, Object) as another method in type X\n" + 
40565
				"----------\n" + 
40566
				"8. WARNING in X.java (at line 9)\n" + 
40567
				"	return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + 
40568
				"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
40569
				"Type safety: Unchecked cast from Object to R\n" + 
40570
				"----------\n";
40377
	this.runNegativeTest(
40571
	this.runNegativeTest(
40378
		new String[] {
40572
		new String[] {
40379
			"X.java",
40573
			"X.java",
Lines 40390-40436 Link Here
40390
			"	public static void main(String[] args) {}\n" +
40584
			"	public static void main(String[] args) {}\n" +
40391
			"}\n", // =================
40585
			"}\n", // =================
40392
		},
40586
		},
40393
		"----------\n" + 
40587
		expectedCompilerLog
40394
		"1. ERROR in X.java (at line 2)\n" + 
40395
		"	public static <S, T extends Comparable<S>, R extends S & T> R max(T arg1, S arg2) {\n" + 
40396
		"	                                                         ^\n" + 
40397
		"Cannot specify any additional bound T when first bound is a type parameter\n" + 
40398
		"----------\n" + 
40399
		"2. ERROR in X.java (at line 2)\n" + 
40400
		"	public static <S, T extends Comparable<S>, R extends S & T> R max(T arg1, S arg2) {\n" + 
40401
		"	                                                              ^^^^^^^^^^^^^^^^^^^\n" + 
40402
		"Method max(T, S) has the same erasure max(Comparable<T>, Object) as another method in type X\n" + 
40403
		"----------\n" + 
40404
		"3. WARNING in X.java (at line 3)\n" + 
40405
		"	return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + 
40406
		"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
40407
		"Type safety: Unchecked cast from Object to R\n" + 
40408
		"----------\n" + 
40409
		"4. ERROR in X.java (at line 5)\n" + 
40410
		"	public static <T extends Comparable<S>, S, R extends S & Comparable<S>> R max(T arg1, S arg2) {\n" + 
40411
		"	                                                         ^^^^^^^^^^\n" + 
40412
		"Cannot specify any additional bound Comparable<S> when first bound is a type parameter\n" + 
40413
		"----------\n" + 
40414
		"5. ERROR in X.java (at line 5)\n" + 
40415
		"	public static <T extends Comparable<S>, S, R extends S & Comparable<S>> R max(T arg1, S arg2) {\n" + 
40416
		"	                                                                          ^^^^^^^^^^^^^^^^^^^\n" + 
40417
		"Method max(T, S) has the same erasure max(Comparable<T>, Object) as another method in type X\n" + 
40418
		"----------\n" + 
40419
		"6. WARNING in X.java (at line 6)\n" + 
40420
		"	return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + 
40421
		"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
40422
		"Type safety: Unchecked cast from Object to R\n" + 
40423
		"----------\n" + 
40424
		"7. ERROR in X.java (at line 8)\n" + 
40425
		"	public static <T extends Comparable<S>, S, R extends Comparable<S>> R max(T arg1, S arg2) {\n" + 
40426
		"	                                                                      ^^^^^^^^^^^^^^^^^^^\n" + 
40427
		"Method max(T, S) has the same erasure max(Comparable<T>, Object) as another method in type X\n" + 
40428
		"----------\n" + 
40429
		"8. WARNING in X.java (at line 9)\n" + 
40430
		"	return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + 
40431
		"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
40432
		"Type safety: Unchecked cast from Object to R\n" + 
40433
		"----------\n"
40434
	);
40588
	);
40435
/*
40589
/*
40436
X.java:2: a type variable may not be followed by other bounds
40590
X.java:2: a type variable may not be followed by other bounds
(-)src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java (-426 / +900 lines)
Lines 27-33 Link Here
27
27
28
public class MethodVerifyTest extends AbstractComparableTest {
28
public class MethodVerifyTest extends AbstractComparableTest {
29
	static {
29
	static {
30
//		TESTS_NAMES = new String[] { "test339447" };
30
//		TESTS_NAMES = new String[] { "test050l" };
31
//		TESTS_NUMBERS = new int[] { 213 };
31
//		TESTS_NUMBERS = new int[] { 213 };
32
//		TESTS_RANGE = new int[] { 190, -1};
32
//		TESTS_RANGE = new int[] { 190, -1};
33
	}
33
	}
Lines 3333-3338 Link Here
3333
3333
3334
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3334
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3335
	public void test048() {
3335
	public void test048() {
3336
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
3337
				"----------\n" + 
3338
				"1. WARNING in X1.java (at line 2)\n" + 
3339
				"	public class X1 extends LinkedHashMap<String, String> {\n" + 
3340
				"	             ^^\n" + 
3341
				"The serializable class X1 does not declare a static final serialVersionUID field of type long\n" + 
3342
				"----------\n" + 
3343
				"2. WARNING in X1.java (at line 3)\n" + 
3344
				"	public Object putAll(Map<String,String> a) { return null; }\n" + 
3345
				"	              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
3346
				"Name clash: The method putAll(Map<String,String>) of type X1 has the same erasure as putAll(Map<? extends K,? extends V>) of type HashMap<K,V> but does not override it\n" + 
3347
				"----------\n":
3348
					"----------\n" + 
3349
					"1. WARNING in X1.java (at line 2)\n" + 
3350
					"	public class X1 extends LinkedHashMap<String, String> {\n" + 
3351
					"	             ^^\n" + 
3352
					"The serializable class X1 does not declare a static final serialVersionUID field of type long\n" + 
3353
					"----------\n" + 
3354
					"2. ERROR in X1.java (at line 3)\n" + 
3355
					"	public Object putAll(Map<String,String> a) { return null; }\n" + 
3356
					"	              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
3357
					"Name clash: The method putAll(Map<String,String>) of type X1 has the same erasure as putAll(Map<? extends K,? extends V>) of type HashMap<K,V> but does not override it\n" + 
3358
					"----------\n";
3336
		this.runNegativeTest(
3359
		this.runNegativeTest(
3337
			new String[] {
3360
			new String[] {
3338
				"X1.java",
3361
				"X1.java",
Lines 3341-3357 Link Here
3341
				"    public Object putAll(Map<String,String> a) { return null; }\n" +
3364
				"    public Object putAll(Map<String,String> a) { return null; }\n" +
3342
				"}\n"
3365
				"}\n"
3343
			},
3366
			},
3344
			"----------\n" + 
3367
			expectedCompilerLog
3345
			"1. WARNING in X1.java (at line 2)\n" + 
3346
			"	public class X1 extends LinkedHashMap<String, String> {\n" + 
3347
			"	             ^^\n" + 
3348
			"The serializable class X1 does not declare a static final serialVersionUID field of type long\n" + 
3349
			"----------\n" + 
3350
			"2. ERROR in X1.java (at line 3)\n" + 
3351
			"	public Object putAll(Map<String,String> a) { return null; }\n" + 
3352
			"	              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
3353
			"Name clash: The method putAll(Map<String,String>) of type X1 has the same erasure as putAll(Map<? extends K,? extends V>) of type HashMap<K,V> but does not override it\n" + 
3354
			"----------\n"
3355
		);
3368
		);
3356
/* javac 7
3369
/* javac 7
3357
X.java:4: name clash: putAll(Map<String,String>) in X1 and putAll(Map<? extends K,? extends V>) in HashMap have the same erasure, yet neither overrides the other
3370
X.java:4: name clash: putAll(Map<String,String>) in X1 and putAll(Map<? extends K,? extends V>) in HashMap have the same erasure, yet neither overrides the other
Lines 3365-3370 Link Here
3365
	}
3378
	}
3366
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3379
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3367
	public void test048a() {
3380
	public void test048a() {
3381
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
3382
				"----------\n" + 
3383
				"1. WARNING in X2.java (at line 2)\n" + 
3384
				"	public Object foo(I<String> z) { return null; }\n" + 
3385
				"	              ^^^^^^^^^^^^^^^^\n" + 
3386
				"Name clash: The method foo(I<String>) of type X2 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + 
3387
				"----------\n":		
3388
					"----------\n" + 
3389
					"1. ERROR in X2.java (at line 2)\n" + 
3390
					"	public Object foo(I<String> z) { return null; }\n" + 
3391
					"	              ^^^^^^^^^^^^^^^^\n" + 
3392
					"Name clash: The method foo(I<String>) of type X2 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + 
3393
					"----------\n";
3368
		this.runNegativeTest(
3394
		this.runNegativeTest(
3369
			new String[] {
3395
			new String[] {
3370
				"X2.java",
3396
				"X2.java",
Lines 3378-3389 Link Here
3378
				"    public void foo(I<? extends T> a);\n" +
3404
				"    public void foo(I<? extends T> a);\n" +
3379
				"}\n"
3405
				"}\n"
3380
			},
3406
			},
3381
			"----------\n" + 
3407
			expectedCompilerLog
3382
			"1. ERROR in X2.java (at line 2)\n" + 
3383
			"	public Object foo(I<String> z) { return null; }\n" + 
3384
			"	              ^^^^^^^^^^^^^^^^\n" + 
3385
			"Name clash: The method foo(I<String>) of type X2 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + 
3386
			"----------\n"
3387
		);
3408
		);
3388
/* javac 7
3409
/* javac 7
3389
X.java:2: name clash: foo(I<String>) in X2 and foo(I<? extends T>) in Y have the same erasure, yet neither overrides the other
3410
X.java:2: name clash: foo(I<String>) in X2 and foo(I<? extends T>) in Y have the same erasure, yet neither overrides the other
Lines 3427-3432 Link Here
3427
	}
3448
	}
3428
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3449
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3429
	public void test048c() {
3450
	public void test048c() {
3451
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
3452
				"----------\n" + 
3453
				"1. WARNING in X4.java (at line 2)\n" + 
3454
				"	public String foo(I<String> z) { return null; }\n" + 
3455
				"	              ^^^^^^^^^^^^^^^^\n" + 
3456
				"Name clash: The method foo(I<String>) of type X4 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + 
3457
				"----------\n":
3458
					"----------\n" + 
3459
					"1. ERROR in X4.java (at line 2)\n" + 
3460
					"	public String foo(I<String> z) { return null; }\n" + 
3461
					"	              ^^^^^^^^^^^^^^^^\n" + 
3462
					"Name clash: The method foo(I<String>) of type X4 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + 
3463
					"----------\n";
3430
		this.runNegativeTest(
3464
		this.runNegativeTest(
3431
			new String[] {
3465
			new String[] {
3432
				"X4.java",
3466
				"X4.java",
Lines 3440-3451 Link Here
3440
				"    public Object foo(I<? extends T> a);\n" +
3474
				"    public Object foo(I<? extends T> a);\n" +
3441
				"}\n"
3475
				"}\n"
3442
			},
3476
			},
3443
			"----------\n" + 
3477
			expectedCompilerLog
3444
			"1. ERROR in X4.java (at line 2)\n" + 
3445
			"	public String foo(I<String> z) { return null; }\n" + 
3446
			"	              ^^^^^^^^^^^^^^^^\n" + 
3447
			"Name clash: The method foo(I<String>) of type X4 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + 
3448
			"----------\n"
3449
		);
3478
		);
3450
/* javac 7
3479
/* javac 7
3451
X.java:2: name clash: foo(I<String>) in X4 and foo(I<? extends T>) in Y have the same erasure, yet neither overrides the other
3480
X.java:2: name clash: foo(I<String>) in X4 and foo(I<? extends T>) in Y have the same erasure, yet neither overrides the other
Lines 3458-3463 Link Here
3458
	}
3487
	}
3459
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3488
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3460
	public void test048d() {
3489
	public void test048d() {
3490
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
3491
				"----------\n" + 
3492
				"1. WARNING in X5.java (at line 2)\n" + 
3493
				"	public Object foo(I<String> z) { return null; }\n" + 
3494
				"	              ^^^^^^^^^^^^^^^^\n" + 
3495
				"Name clash: The method foo(I<String>) of type X5 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + 
3496
				"----------\n":
3497
					"----------\n" + 
3498
					"1. ERROR in X5.java (at line 2)\n" + 
3499
					"	public Object foo(I<String> z) { return null; }\n" + 
3500
					"	              ^^^^^^^^^^^^^^^^\n" + 
3501
					"Name clash: The method foo(I<String>) of type X5 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + 
3502
					"----------\n";
3461
		this.runNegativeTest(
3503
		this.runNegativeTest(
3462
			new String[] {
3504
			new String[] {
3463
				"X5.java",
3505
				"X5.java",
Lines 3471-3482 Link Here
3471
				"    public String foo(I<? extends T> a);\n" +
3513
				"    public String foo(I<? extends T> a);\n" +
3472
				"}\n"
3514
				"}\n"
3473
			},
3515
			},
3474
			"----------\n" + 
3516
			expectedCompilerLog
3475
			"1. ERROR in X5.java (at line 2)\n" + 
3476
			"	public Object foo(I<String> z) { return null; }\n" + 
3477
			"	              ^^^^^^^^^^^^^^^^\n" + 
3478
			"Name clash: The method foo(I<String>) of type X5 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + 
3479
			"----------\n"
3480
		);
3517
		);
3481
/* javac 7
3518
/* javac 7
3482
X.java:2: name clash: foo(I<String>) in X5 and foo(I<? extends T>) in Y have the
3519
X.java:2: name clash: foo(I<String>) in X5 and foo(I<? extends T>) in Y have the
Lines 3490-3495 Link Here
3490
	}
3527
	}
3491
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3528
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3492
	public void test048e() {
3529
	public void test048e() {
3530
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
3531
				"----------\n" + 
3532
				"1. WARNING in X6.java (at line 2)\n" + 
3533
				"	public void foo(I<String> z) {}\n" + 
3534
				"	            ^^^^^^^^^^^^^^^^\n" + 
3535
				"Name clash: The method foo(I<String>) of type X6 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + 
3536
				"----------\n":
3537
					"----------\n" + 
3538
					"1. ERROR in X6.java (at line 2)\n" + 
3539
					"	public void foo(I<String> z) {}\n" + 
3540
					"	            ^^^^^^^^^^^^^^^^\n" + 
3541
					"Name clash: The method foo(I<String>) of type X6 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + 
3542
					"----------\n";
3493
		this.runNegativeTest(
3543
		this.runNegativeTest(
3494
			new String[] {
3544
			new String[] {
3495
				"X6.java",
3545
				"X6.java",
Lines 3503-3514 Link Here
3503
				"    public Object foo(I<? extends T> a);\n" +
3553
				"    public Object foo(I<? extends T> a);\n" +
3504
				"}\n"
3554
				"}\n"
3505
			},
3555
			},
3506
			"----------\n" + 
3556
			expectedCompilerLog
3507
			"1. ERROR in X6.java (at line 2)\n" + 
3508
			"	public void foo(I<String> z) {}\n" + 
3509
			"	            ^^^^^^^^^^^^^^^^\n" + 
3510
			"Name clash: The method foo(I<String>) of type X6 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + 
3511
			"----------\n"
3512
		);
3557
		);
3513
/* javac 7
3558
/* javac 7
3514
X.java:2: name clash: foo(I<String>) in X6 and foo(I<? extends T>) in Y have the same erasure, yet neither overrides the other
3559
X.java:2: name clash: foo(I<String>) in X6 and foo(I<? extends T>) in Y have the same erasure, yet neither overrides the other
Lines 3521-3526 Link Here
3521
	}
3566
	}
3522
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3567
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3523
	public void test048f() {
3568
	public void test048f() {
3569
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
3570
				"----------\n" + 
3571
				"1. WARNING in X7.java (at line 2)\n" + 
3572
				"	public String foo(I<String> z) { return null; }\n" + 
3573
				"	              ^^^^^^^^^^^^^^^^\n" + 
3574
				"Name clash: The method foo(I<String>) of type X7 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + 
3575
				"----------\n":
3576
					"----------\n" + 
3577
					"1. ERROR in X7.java (at line 2)\n" + 
3578
					"	public String foo(I<String> z) { return null; }\n" + 
3579
					"	              ^^^^^^^^^^^^^^^^\n" + 
3580
					"Name clash: The method foo(I<String>) of type X7 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + 
3581
					"----------\n";
3524
		this.runNegativeTest(
3582
		this.runNegativeTest(
3525
			new String[] {
3583
			new String[] {
3526
				"X7.java",
3584
				"X7.java",
Lines 3534-3545 Link Here
3534
				"    public T foo(I<? extends T> a);\n" +
3592
				"    public T foo(I<? extends T> a);\n" +
3535
				"}\n"
3593
				"}\n"
3536
			},
3594
			},
3537
			"----------\n" + 
3595
			expectedCompilerLog
3538
			"1. ERROR in X7.java (at line 2)\n" + 
3539
			"	public String foo(I<String> z) { return null; }\n" + 
3540
			"	              ^^^^^^^^^^^^^^^^\n" + 
3541
			"Name clash: The method foo(I<String>) of type X7 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" + 
3542
			"----------\n"
3543
		);
3596
		);
3544
/* javac 7
3597
/* javac 7
3545
X.java:2: name clash: foo(I<String>) in X7 and foo(I<? extends T>) in Y have the same erasure, yet neither overrides the other
3598
X.java:2: name clash: foo(I<String>) in X7 and foo(I<? extends T>) in Y have the same erasure, yet neither overrides the other
Lines 3642-3647 Link Here
3642
3695
3643
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=94754
3696
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=94754
3644
	public void test050() {
3697
	public void test050() {
3698
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
3699
				"----------\n" + 
3700
				"1. WARNING in X.java (at line 2)\n" + 
3701
				"	public static <S extends A> S foo() { System.out.print(\"A\"); return null; }\n" + 
3702
				"	                              ^^^^^\n" + 
3703
				"Duplicate method foo() in type X\n" + 
3704
				"----------\n" + 
3705
				"2. WARNING in X.java (at line 3)\n" + 
3706
				"	public static <N extends B> N foo() { System.out.print(\"B\"); return null; }\n" + 
3707
				"	                              ^^^^^\n" + 
3708
				"Duplicate method foo() in type X\n" + 
3709
				"----------\n" + 
3710
				"3. WARNING in X.java (at line 7)\n" + 
3711
				"	new X().<B>foo();\n" + 
3712
				"	^^^^^^^^^^^^^^^^\n" + 
3713
				"The static method foo() from the type X should be accessed in a static way\n" + 
3714
				"----------\n":
3715
					"----------\n" + 
3716
					"1. ERROR in X.java (at line 2)\n" + 
3717
					"	public static <S extends A> S foo() { System.out.print(\"A\"); return null; }\n" + 
3718
					"	                              ^^^^^\n" + 
3719
					"Duplicate method foo() in type X\n" + 
3720
					"----------\n" + 
3721
					"2. ERROR in X.java (at line 3)\n" + 
3722
					"	public static <N extends B> N foo() { System.out.print(\"B\"); return null; }\n" + 
3723
					"	                              ^^^^^\n" + 
3724
					"Duplicate method foo() in type X\n" + 
3725
					"----------\n" + 
3726
					"3. ERROR in X.java (at line 6)\n" + 
3727
					"	X.<B>foo();\n" + 
3728
					"	     ^^^\n" + 
3729
					"Bound mismatch: The generic method foo() of type X is not applicable for the arguments (). The inferred type B is not a valid substitute for the bounded parameter <S extends A>\n" + 
3730
					"----------\n" + 
3731
					"4. ERROR in X.java (at line 7)\n" + 
3732
					"	new X().<B>foo();\n" + 
3733
					"	           ^^^\n" + 
3734
					"Bound mismatch: The generic method foo() of type X is not applicable for the arguments (). The inferred type B is not a valid substitute for the bounded parameter <S extends A>\n" + 
3735
					"----------\n";
3645
		this.runNegativeTest(
3736
		this.runNegativeTest(
3646
			new String[] {
3737
			new String[] {
3647
				"X.java",
3738
				"X.java",
Lines 3657-3683 Link Here
3657
				"class A {}\n" +
3748
				"class A {}\n" +
3658
				"class B {}"
3749
				"class B {}"
3659
			},
3750
			},
3660
			"----------\n" + 
3751
			expectedCompilerLog
3661
			"1. ERROR in X.java (at line 2)\n" + 
3662
			"	public static <S extends A> S foo() { System.out.print(\"A\"); return null; }\n" + 
3663
			"	                              ^^^^^\n" + 
3664
			"Duplicate method foo() in type X\n" + 
3665
			"----------\n" + 
3666
			"2. ERROR in X.java (at line 3)\n" + 
3667
			"	public static <N extends B> N foo() { System.out.print(\"B\"); return null; }\n" + 
3668
			"	                              ^^^^^\n" + 
3669
			"Duplicate method foo() in type X\n" + 
3670
			"----------\n" + 
3671
			"3. ERROR in X.java (at line 6)\n" + 
3672
			"	X.<B>foo();\n" + 
3673
			"	     ^^^\n" + 
3674
			"Bound mismatch: The generic method foo() of type X is not applicable for the arguments (). The inferred type B is not a valid substitute for the bounded parameter <S extends A>\n" + 
3675
			"----------\n" + 
3676
			"4. ERROR in X.java (at line 7)\n" + 
3677
			"	new X().<B>foo();\n" + 
3678
			"	           ^^^\n" + 
3679
			"Bound mismatch: The generic method foo() of type X is not applicable for the arguments (). The inferred type B is not a valid substitute for the bounded parameter <S extends A>\n" + 
3680
			"----------\n"
3681
		);
3752
		);
3682
/* javac 7
3753
/* javac 7
3683
X.java:3: name clash: <N>foo() and <S>foo() have the same erasure
3754
X.java:3: name clash: <N>foo() and <S>foo() have the same erasure
Lines 3701-3706 Link Here
3701
	}
3772
	}
3702
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=94754
3773
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=94754
3703
	public void test050a() {
3774
	public void test050a() {
3775
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
3776
				"----------\n" + 
3777
				"1. WARNING in X.java (at line 2)\n" + 
3778
				"	public static <S extends A> void foo() { System.out.print(\"A\"); }\n" + 
3779
				"	                                 ^^^^^\n" + 
3780
				"Duplicate method foo() in type X\n" + 
3781
				"----------\n" + 
3782
				"2. WARNING in X.java (at line 3)\n" + 
3783
				"	public static <N extends B> N foo() { System.out.print(\"B\"); return null; }\n" + 
3784
				"	                              ^^^^^\n" + 
3785
				"Duplicate method foo() in type X\n" + 
3786
				"----------\n" + 
3787
				"3. ERROR in X.java (at line 5)\n" + 
3788
				"	X.foo();\n" + 
3789
				"	  ^^^\n" + 
3790
				"The method foo() is ambiguous for the type X\n" + 
3791
				"----------\n" + 
3792
				"4. ERROR in X.java (at line 6)\n" + 
3793
				"	foo();\n" + 
3794
				"	^^^\n" + 
3795
				"The method foo() is ambiguous for the type X\n" + 
3796
				"----------\n":
3797
					"----------\n" + 
3798
					"1. ERROR in X.java (at line 2)\n" + 
3799
					"	public static <S extends A> void foo() { System.out.print(\"A\"); }\n" + 
3800
					"	                                 ^^^^^\n" + 
3801
					"Duplicate method foo() in type X\n" + 
3802
					"----------\n" + 
3803
					"2. ERROR in X.java (at line 3)\n" + 
3804
					"	public static <N extends B> N foo() { System.out.print(\"B\"); return null; }\n" + 
3805
					"	                              ^^^^^\n" + 
3806
					"Duplicate method foo() in type X\n" + 
3807
					"----------\n";
3704
		this.runNegativeTest(
3808
		this.runNegativeTest(
3705
			new String[] {
3809
			new String[] {
3706
				"X.java",
3810
				"X.java",
Lines 3715-3731 Link Here
3715
				"class A {}\n" +
3819
				"class A {}\n" +
3716
				"class B {}"
3820
				"class B {}"
3717
			},
3821
			},
3718
			"----------\n" + 
3822
			expectedCompilerLog
3719
			"1. ERROR in X.java (at line 2)\n" + 
3720
			"	public static <S extends A> void foo() { System.out.print(\"A\"); }\n" + 
3721
			"	                                 ^^^^^\n" + 
3722
			"Duplicate method foo() in type X\n" + 
3723
			"----------\n" + 
3724
			"2. ERROR in X.java (at line 3)\n" + 
3725
			"	public static <N extends B> N foo() { System.out.print(\"B\"); return null; }\n" + 
3726
			"	                              ^^^^^\n" + 
3727
			"Duplicate method foo() in type X\n" + 
3728
			"----------\n"
3729
		);
3823
		);
3730
/* javac 7
3824
/* javac 7
3731
X.java:3: name clash: <N>foo() and <S>foo() have the same erasure
3825
X.java:3: name clash: <N>foo() and <S>foo() have the same erasure
Lines 3740-3745 Link Here
3740
3834
3741
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation
3835
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation
3742
	public void test050b() {
3836
	public void test050b() {
3837
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
3838
				"----------\n" + 
3839
				"1. ERROR in X.java (at line 3)\n" + 
3840
				"	Y foo(Object o) {  return null; } // duplicate\n" + 
3841
				"	  ^^^^^^^^^^^^^\n" + 
3842
				"Duplicate method foo(Object) in type X.C1\n" + 
3843
				"----------\n" + 
3844
				"2. ERROR in X.java (at line 4)\n" + 
3845
				"	Z foo(Object o) {  return null; } // duplicate\n" + 
3846
				"	  ^^^^^^^^^^^^^\n" + 
3847
				"Duplicate method foo(Object) in type X.C1\n" + 
3848
				"----------\n" + 
3849
				"3. WARNING in X.java (at line 7)\n" + 
3850
				"	<T extends Y> T foo(Object o) {  return null; } // duplicate\n" + 
3851
				"	                ^^^^^^^^^^^^^\n" + 
3852
				"Duplicate method foo(Object) in type X.C2\n" + 
3853
				"----------\n" + 
3854
				"4. WARNING in X.java (at line 8)\n" + 
3855
				"	<T extends Z> T foo(Object o) {  return null; } // duplicate\n" + 
3856
				"	                ^^^^^^^^^^^^^\n" + 
3857
				"Duplicate method foo(Object) in type X.C2\n" + 
3858
				"----------\n" + 
3859
				"5. ERROR in X.java (at line 11)\n" + 
3860
				"	A<Y> foo(Object o) {  return null; } // duplicate\n" + 
3861
				"	     ^^^^^^^^^^^^^\n" + 
3862
				"Duplicate method foo(Object) in type X.C3\n" + 
3863
				"----------\n" + 
3864
				"6. ERROR in X.java (at line 12)\n" + 
3865
				"	A<Z> foo(Object o) {  return null; } // duplicate\n" + 
3866
				"	     ^^^^^^^^^^^^^\n" + 
3867
				"Duplicate method foo(Object) in type X.C3\n" + 
3868
				"----------\n" + 
3869
				"7. WARNING in X.java (at line 15)\n" + 
3870
				"	Y foo(Object o) {  return null; } // duplicate\n" + 
3871
				"	  ^^^^^^^^^^^^^\n" + 
3872
				"Duplicate method foo(Object) in type X.C4\n" + 
3873
				"----------\n" + 
3874
				"8. WARNING in X.java (at line 16)\n" + 
3875
				"	<T extends Z> T foo(Object o) {  return null; } // duplicate\n" + 
3876
				"	                ^^^^^^^^^^^^^\n" + 
3877
				"Duplicate method foo(Object) in type X.C4\n" + 
3878
				"----------\n":
3879
					"----------\n" + 
3880
					"1. ERROR in X.java (at line 3)\n" + 
3881
					"	Y foo(Object o) {  return null; } // duplicate\n" + 
3882
					"	  ^^^^^^^^^^^^^\n" + 
3883
					"Duplicate method foo(Object) in type X.C1\n" + 
3884
					"----------\n" + 
3885
					"2. ERROR in X.java (at line 4)\n" + 
3886
					"	Z foo(Object o) {  return null; } // duplicate\n" + 
3887
					"	  ^^^^^^^^^^^^^\n" + 
3888
					"Duplicate method foo(Object) in type X.C1\n" + 
3889
					"----------\n" + 
3890
					"3. ERROR in X.java (at line 7)\n" + 
3891
					"	<T extends Y> T foo(Object o) {  return null; } // duplicate\n" + 
3892
					"	                ^^^^^^^^^^^^^\n" + 
3893
					"Duplicate method foo(Object) in type X.C2\n" + 
3894
					"----------\n" + 
3895
					"4. ERROR in X.java (at line 8)\n" + 
3896
					"	<T extends Z> T foo(Object o) {  return null; } // duplicate\n" + 
3897
					"	                ^^^^^^^^^^^^^\n" + 
3898
					"Duplicate method foo(Object) in type X.C2\n" + 
3899
					"----------\n" + 
3900
					"5. ERROR in X.java (at line 11)\n" + 
3901
					"	A<Y> foo(Object o) {  return null; } // duplicate\n" + 
3902
					"	     ^^^^^^^^^^^^^\n" + 
3903
					"Duplicate method foo(Object) in type X.C3\n" + 
3904
					"----------\n" + 
3905
					"6. ERROR in X.java (at line 12)\n" + 
3906
					"	A<Z> foo(Object o) {  return null; } // duplicate\n" + 
3907
					"	     ^^^^^^^^^^^^^\n" + 
3908
					"Duplicate method foo(Object) in type X.C3\n" + 
3909
					"----------\n" + 
3910
					"7. ERROR in X.java (at line 15)\n" + 
3911
					"	Y foo(Object o) {  return null; } // duplicate\n" + 
3912
					"	  ^^^^^^^^^^^^^\n" + 
3913
					"Duplicate method foo(Object) in type X.C4\n" + 
3914
					"----------\n" + 
3915
					"8. ERROR in X.java (at line 16)\n" + 
3916
					"	<T extends Z> T foo(Object o) {  return null; } // duplicate\n" + 
3917
					"	                ^^^^^^^^^^^^^\n" + 
3918
					"Duplicate method foo(Object) in type X.C4\n" + 
3919
					"----------\n";
3743
		this.runNegativeTest(
3920
		this.runNegativeTest(
3744
			new String[] {
3921
			new String[] {
3745
				"X.java",
3922
				"X.java",
Lines 3765-3811 Link Here
3765
				"class Y {}\n" +
3942
				"class Y {}\n" +
3766
				"class Z {}"
3943
				"class Z {}"
3767
			},
3944
			},
3768
			"----------\n" + 
3945
			expectedCompilerLog
3769
			"1. ERROR in X.java (at line 3)\n" + 
3770
			"	Y foo(Object o) {  return null; } // duplicate\n" + 
3771
			"	  ^^^^^^^^^^^^^\n" + 
3772
			"Duplicate method foo(Object) in type X.C1\n" + 
3773
			"----------\n" + 
3774
			"2. ERROR in X.java (at line 4)\n" + 
3775
			"	Z foo(Object o) {  return null; } // duplicate\n" + 
3776
			"	  ^^^^^^^^^^^^^\n" + 
3777
			"Duplicate method foo(Object) in type X.C1\n" + 
3778
			"----------\n" + 
3779
			"3. ERROR in X.java (at line 7)\n" + 
3780
			"	<T extends Y> T foo(Object o) {  return null; } // duplicate\n" + 
3781
			"	                ^^^^^^^^^^^^^\n" + 
3782
			"Duplicate method foo(Object) in type X.C2\n" + 
3783
			"----------\n" + 
3784
			"4. ERROR in X.java (at line 8)\n" + 
3785
			"	<T extends Z> T foo(Object o) {  return null; } // duplicate\n" + 
3786
			"	                ^^^^^^^^^^^^^\n" + 
3787
			"Duplicate method foo(Object) in type X.C2\n" + 
3788
			"----------\n" + 
3789
			"5. ERROR in X.java (at line 11)\n" + 
3790
			"	A<Y> foo(Object o) {  return null; } // duplicate\n" + 
3791
			"	     ^^^^^^^^^^^^^\n" + 
3792
			"Duplicate method foo(Object) in type X.C3\n" + 
3793
			"----------\n" + 
3794
			"6. ERROR in X.java (at line 12)\n" + 
3795
			"	A<Z> foo(Object o) {  return null; } // duplicate\n" + 
3796
			"	     ^^^^^^^^^^^^^\n" + 
3797
			"Duplicate method foo(Object) in type X.C3\n" + 
3798
			"----------\n" + 
3799
			"7. ERROR in X.java (at line 15)\n" + 
3800
			"	Y foo(Object o) {  return null; } // duplicate\n" + 
3801
			"	  ^^^^^^^^^^^^^\n" + 
3802
			"Duplicate method foo(Object) in type X.C4\n" + 
3803
			"----------\n" + 
3804
			"8. ERROR in X.java (at line 16)\n" + 
3805
			"	<T extends Z> T foo(Object o) {  return null; } // duplicate\n" + 
3806
			"	                ^^^^^^^^^^^^^\n" + 
3807
			"Duplicate method foo(Object) in type X.C4\n" + 
3808
			"----------\n"
3809
		);
3946
		);
3810
/* javac 7
3947
/* javac 7
3811
X.java:4: foo(Object) is already defined in X.C1
3948
X.java:4: foo(Object) is already defined in X.C1
Lines 3828-3833 Link Here
3828
	}
3965
	}
3829
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation
3966
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation
3830
	public void test050c() {
3967
	public void test050c() {
3968
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
3969
				"----------\n" + 
3970
				"1. ERROR in X.java (at line 3)\n" + 
3971
				"	A<Y> foo(A<Y> o) {  return null; } // duplicate\n" + 
3972
				"	     ^^^^^^^^^^^\n" + 
3973
				"Method foo(A<Y>) has the same erasure foo(A<T>) as another method in type X.C5\n" + 
3974
				"----------\n" + 
3975
				"2. ERROR in X.java (at line 4)\n" + 
3976
				"	A<Z> foo(A<Z> o) {  return null; } // duplicate\n" + 
3977
				"	     ^^^^^^^^^^^\n" + 
3978
				"Method foo(A<Z>) has the same erasure foo(A<T>) as another method in type X.C5\n" + 
3979
				"----------\n" + 
3980
				"3. WARNING in X.java (at line 7)\n" + 
3981
				"	<T extends Y> T foo(A<Y> o) {  return null; } // ok\n" + 
3982
				"	                ^^^^^^^^^^^\n" + 
3983
				"Method foo(A<Y>) has the same erasure foo(A<T>) as another method in type X.C6\n" + 
3984
				"----------\n" + 
3985
				"4. WARNING in X.java (at line 8)\n" + 
3986
				"	<T extends Z> T foo(A<Z> o) {  return null; } // ok\n" + 
3987
				"	                ^^^^^^^^^^^\n" + 
3988
				"Method foo(A<Z>) has the same erasure foo(A<T>) as another method in type X.C6\n" + 
3989
				"----------\n":
3990
					"----------\n" + 
3991
					"1. ERROR in X.java (at line 3)\n" + 
3992
					"	A<Y> foo(A<Y> o) {  return null; } // duplicate\n" + 
3993
					"	     ^^^^^^^^^^^\n" + 
3994
					"Method foo(A<Y>) has the same erasure foo(A<T>) as another method in type X.C5\n" + 
3995
					"----------\n" + 
3996
					"2. ERROR in X.java (at line 4)\n" + 
3997
					"	A<Z> foo(A<Z> o) {  return null; } // duplicate\n" + 
3998
					"	     ^^^^^^^^^^^\n" + 
3999
					"Method foo(A<Z>) has the same erasure foo(A<T>) as another method in type X.C5\n" + 
4000
					"----------\n" + 
4001
					"3. ERROR in X.java (at line 7)\n" + 
4002
					"	<T extends Y> T foo(A<Y> o) {  return null; } // ok\n" + 
4003
					"	                ^^^^^^^^^^^\n" + 
4004
					"Method foo(A<Y>) has the same erasure foo(A<T>) as another method in type X.C6\n" + 
4005
					"----------\n" + 
4006
					"4. ERROR in X.java (at line 8)\n" + 
4007
					"	<T extends Z> T foo(A<Z> o) {  return null; } // ok\n" + 
4008
					"	                ^^^^^^^^^^^\n" + 
4009
					"Method foo(A<Z>) has the same erasure foo(A<T>) as another method in type X.C6\n" + 
4010
					"----------\n";
3831
		this.runNegativeTest(
4011
		this.runNegativeTest(
3832
			new String[] {
4012
			new String[] {
3833
				"X.java",
4013
				"X.java",
Lines 3845-3871 Link Here
3845
				"class Y {}\n" +
4025
				"class Y {}\n" +
3846
				"class Z {}"
4026
				"class Z {}"
3847
			},
4027
			},
3848
			"----------\n" + 
4028
			expectedCompilerLog
3849
			"1. ERROR in X.java (at line 3)\n" + 
3850
			"	A<Y> foo(A<Y> o) {  return null; } // duplicate\n" + 
3851
			"	     ^^^^^^^^^^^\n" + 
3852
			"Method foo(A<Y>) has the same erasure foo(A<T>) as another method in type X.C5\n" + 
3853
			"----------\n" + 
3854
			"2. ERROR in X.java (at line 4)\n" + 
3855
			"	A<Z> foo(A<Z> o) {  return null; } // duplicate\n" + 
3856
			"	     ^^^^^^^^^^^\n" + 
3857
			"Method foo(A<Z>) has the same erasure foo(A<T>) as another method in type X.C5\n" + 
3858
			"----------\n" + 
3859
			"3. ERROR in X.java (at line 7)\n" + 
3860
			"	<T extends Y> T foo(A<Y> o) {  return null; } // ok\n" + 
3861
			"	                ^^^^^^^^^^^\n" + 
3862
			"Method foo(A<Y>) has the same erasure foo(A<T>) as another method in type X.C6\n" + 
3863
			"----------\n" + 
3864
			"4. ERROR in X.java (at line 8)\n" + 
3865
			"	<T extends Z> T foo(A<Z> o) {  return null; } // ok\n" + 
3866
			"	                ^^^^^^^^^^^\n" + 
3867
			"Method foo(A<Z>) has the same erasure foo(A<T>) as another method in type X.C6\n" + 
3868
			"----------\n"
3869
		);
4029
		);
3870
/* javac 7
4030
/* javac 7
3871
X.java:4: name clash: foo(A<Z>) and foo(A<Y>) have the same erasure
4031
X.java:4: name clash: foo(A<Z>) and foo(A<Y>) have the same erasure
Lines 3882-3887 Link Here
3882
	}
4042
	}
3883
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation
4043
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation
3884
	public void test050d() {
4044
	public void test050d() {
4045
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
4046
				"----------\n" + 
4047
				"1. WARNING in X.java (at line 3)\n" + 
4048
				"	<T extends Y, U> T foo(Object o) {  return null; } // ok\n" + 
4049
				"	                   ^^^^^^^^^^^^^\n" + 
4050
				"Duplicate method foo(Object) in type X.C7\n" + 
4051
				"----------\n" + 
4052
				"2. WARNING in X.java (at line 4)\n" + 
4053
				"	<T extends Z> T foo(Object o) {  return null; } // ok\n" + 
4054
				"	                ^^^^^^^^^^^^^\n" + 
4055
				"Duplicate method foo(Object) in type X.C7\n" + 
4056
				"----------\n":
4057
					"----------\n" + 
4058
					"1. ERROR in X.java (at line 3)\n" + 
4059
					"	<T extends Y, U> T foo(Object o) {  return null; } // ok\n" + 
4060
					"	                   ^^^^^^^^^^^^^\n" + 
4061
					"Duplicate method foo(Object) in type X.C7\n" + 
4062
					"----------\n" + 
4063
					"2. ERROR in X.java (at line 4)\n" + 
4064
					"	<T extends Z> T foo(Object o) {  return null; } // ok\n" + 
4065
					"	                ^^^^^^^^^^^^^\n" + 
4066
					"Duplicate method foo(Object) in type X.C7\n" + 
4067
					"----------\n";
3885
		this.runNegativeTest(
4068
		this.runNegativeTest(
3886
			new String[] {
4069
			new String[] {
3887
				"X.java",
4070
				"X.java",
Lines 3895-3911 Link Here
3895
				"class Y {}\n" +
4078
				"class Y {}\n" +
3896
				"class Z {}"
4079
				"class Z {}"
3897
			},
4080
			},
3898
			"----------\n" + 
4081
			expectedCompilerLog
3899
			"1. ERROR in X.java (at line 3)\n" + 
3900
			"	<T extends Y, U> T foo(Object o) {  return null; } // ok\n" + 
3901
			"	                   ^^^^^^^^^^^^^\n" + 
3902
			"Duplicate method foo(Object) in type X.C7\n" + 
3903
			"----------\n" + 
3904
			"2. ERROR in X.java (at line 4)\n" + 
3905
			"	<T extends Z> T foo(Object o) {  return null; } // ok\n" + 
3906
			"	                ^^^^^^^^^^^^^\n" + 
3907
			"Duplicate method foo(Object) in type X.C7\n" + 
3908
			"----------\n"
3909
		);
4082
		);
3910
/* javac 7
4083
/* javac 7
3911
X.java:4: name clash: <T#1>foo(Object) and <T#2,U>foo(Object) have the same erasure
4084
X.java:4: name clash: <T#1>foo(Object) and <T#2,U>foo(Object) have the same erasure
Lines 3921-3926 Link Here
3921
4094
3922
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423
4095
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423
3923
	public void test050e() {
4096
	public void test050e() {
4097
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
4098
				"----------\n" + 
4099
				"1. WARNING in X.java (at line 2)\n" + 
4100
				"	<N extends B> N a(A<String> s) { return null; }\n" + 
4101
				"	                ^^^^^^^^^^^^^^\n" + 
4102
				"Method a(A<String>) has the same erasure a(A<T>) as another method in type X\n" + 
4103
				"----------\n" + 
4104
				"2. WARNING in X.java (at line 3)\n" + 
4105
				"	<N> Object a(A<Number> n) { return null; }\n" + 
4106
				"	           ^^^^^^^^^^^^^^\n" + 
4107
				"Method a(A<Number>) has the same erasure a(A<T>) as another method in type X\n" + 
4108
				"----------\n" + 
4109
				"3. WARNING in X.java (at line 4)\n" + 
4110
				"	<N extends B> void b(A<String> s) {}\n" + 
4111
				"	                   ^^^^^^^^^^^^^^\n" + 
4112
				"Method b(A<String>) has the same erasure b(A<T>) as another method in type X\n" + 
4113
				"----------\n" + 
4114
				"4. WARNING in X.java (at line 5)\n" + 
4115
				"	<N extends B> B b(A<Number> n) { return null; }\n" + 
4116
				"	                ^^^^^^^^^^^^^^\n" + 
4117
				"Method b(A<Number>) has the same erasure b(A<T>) as another method in type X\n" + 
4118
				"----------\n" + 
4119
				"5. WARNING in X.java (at line 6)\n" + 
4120
				"	void c(A<String> s) {}\n" + 
4121
				"	     ^^^^^^^^^^^^^^\n" + 
4122
				"Method c(A<String>) has the same erasure c(A<T>) as another method in type X\n" + 
4123
				"----------\n" + 
4124
				"6. WARNING in X.java (at line 7)\n" + 
4125
				"	B c(A<Number> n) { return null; }\n" + 
4126
				"	  ^^^^^^^^^^^^^^\n" + 
4127
				"Method c(A<Number>) has the same erasure c(A<T>) as another method in type X\n" + 
4128
				"----------\n":
4129
					"----------\n" + 
4130
					"1. ERROR in X.java (at line 2)\n" + 
4131
					"	<N extends B> N a(A<String> s) { return null; }\n" + 
4132
					"	                ^^^^^^^^^^^^^^\n" + 
4133
					"Method a(A<String>) has the same erasure a(A<T>) as another method in type X\n" + 
4134
					"----------\n" + 
4135
					"2. ERROR in X.java (at line 3)\n" + 
4136
					"	<N> Object a(A<Number> n) { return null; }\n" + 
4137
					"	           ^^^^^^^^^^^^^^\n" + 
4138
					"Method a(A<Number>) has the same erasure a(A<T>) as another method in type X\n" + 
4139
					"----------\n" + 
4140
					"3. ERROR in X.java (at line 4)\n" + 
4141
					"	<N extends B> void b(A<String> s) {}\n" + 
4142
					"	                   ^^^^^^^^^^^^^^\n" + 
4143
					"Method b(A<String>) has the same erasure b(A<T>) as another method in type X\n" + 
4144
					"----------\n" + 
4145
					"4. ERROR in X.java (at line 5)\n" + 
4146
					"	<N extends B> B b(A<Number> n) { return null; }\n" + 
4147
					"	                ^^^^^^^^^^^^^^\n" + 
4148
					"Method b(A<Number>) has the same erasure b(A<T>) as another method in type X\n" + 
4149
					"----------\n" + 
4150
					"5. ERROR in X.java (at line 6)\n" + 
4151
					"	void c(A<String> s) {}\n" + 
4152
					"	     ^^^^^^^^^^^^^^\n" + 
4153
					"Method c(A<String>) has the same erasure c(A<T>) as another method in type X\n" + 
4154
					"----------\n" + 
4155
					"6. ERROR in X.java (at line 7)\n" + 
4156
					"	B c(A<Number> n) { return null; }\n" + 
4157
					"	  ^^^^^^^^^^^^^^\n" + 
4158
					"Method c(A<Number>) has the same erasure c(A<T>) as another method in type X\n" + 
4159
					"----------\n";
3924
		this.runNegativeTest(
4160
		this.runNegativeTest(
3925
			new String[] {
4161
			new String[] {
3926
				"X.java",
4162
				"X.java",
Lines 3935-3971 Link Here
3935
				"class A<T> {}\n" +
4171
				"class A<T> {}\n" +
3936
				"class B {}\n"
4172
				"class B {}\n"
3937
			},
4173
			},
3938
			"----------\n" + 
4174
			expectedCompilerLog
3939
			"1. ERROR in X.java (at line 2)\n" + 
3940
			"	<N extends B> N a(A<String> s) { return null; }\n" + 
3941
			"	                ^^^^^^^^^^^^^^\n" + 
3942
			"Method a(A<String>) has the same erasure a(A<T>) as another method in type X\n" + 
3943
			"----------\n" + 
3944
			"2. ERROR in X.java (at line 3)\n" + 
3945
			"	<N> Object a(A<Number> n) { return null; }\n" + 
3946
			"	           ^^^^^^^^^^^^^^\n" + 
3947
			"Method a(A<Number>) has the same erasure a(A<T>) as another method in type X\n" + 
3948
			"----------\n" + 
3949
			"3. ERROR in X.java (at line 4)\n" + 
3950
			"	<N extends B> void b(A<String> s) {}\n" + 
3951
			"	                   ^^^^^^^^^^^^^^\n" + 
3952
			"Method b(A<String>) has the same erasure b(A<T>) as another method in type X\n" + 
3953
			"----------\n" + 
3954
			"4. ERROR in X.java (at line 5)\n" + 
3955
			"	<N extends B> B b(A<Number> n) { return null; }\n" + 
3956
			"	                ^^^^^^^^^^^^^^\n" + 
3957
			"Method b(A<Number>) has the same erasure b(A<T>) as another method in type X\n" + 
3958
			"----------\n" + 
3959
			"5. ERROR in X.java (at line 6)\n" + 
3960
			"	void c(A<String> s) {}\n" + 
3961
			"	     ^^^^^^^^^^^^^^\n" + 
3962
			"Method c(A<String>) has the same erasure c(A<T>) as another method in type X\n" + 
3963
			"----------\n" + 
3964
			"6. ERROR in X.java (at line 7)\n" + 
3965
			"	B c(A<Number> n) { return null; }\n" + 
3966
			"	  ^^^^^^^^^^^^^^\n" + 
3967
			"Method c(A<Number>) has the same erasure c(A<T>) as another method in type X\n" + 
3968
			"----------\n"
3969
		);
4175
		);
3970
/* javac 7
4176
/* javac 7
3971
X.java:3: name clash: <N#1>a(A<Number>) and <N#2>a(A<String>) have the same erasure
4177
X.java:3: name clash: <N#1>a(A<Number>) and <N#2>a(A<String>) have the same erasure
Lines 4088-4093 Link Here
4088
4294
4089
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423
4295
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423
4090
	public void test050i() {
4296
	public void test050i() {
4297
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
4298
				"----------\n" + 
4299
				"1. WARNING in X.java (at line 2)\n" + 
4300
				"	<N extends B> N a(A<Number> s) { return null; }\n" + 
4301
				"	                ^^^^^^^^^^^^^^\n" + 
4302
				"Duplicate method a(A<Number>) in type X\n" + 
4303
				"----------\n" + 
4304
				"2. WARNING in X.java (at line 3)\n" + 
4305
				"	<N> Object a(A<Number> n) { return null; }\n" + 
4306
				"	           ^^^^^^^^^^^^^^\n" + 
4307
				"Duplicate method a(A<Number>) in type X\n" + 
4308
				"----------\n" + 
4309
				"3. WARNING in X.java (at line 4)\n" + 
4310
				"	<N extends B> N b(A<Number> s) { return null; }\n" + 
4311
				"	                ^^^^^^^^^^^^^^\n" + 
4312
				"Method b(A<Number>) has the same erasure b(A<T>) as another method in type X\n" + 
4313
				"----------\n" + 
4314
				"4. WARNING in X.java (at line 5)\n" + 
4315
				"	<N> Object b(A<String> n) { return null; }\n" + 
4316
				"	           ^^^^^^^^^^^^^^\n" + 
4317
				"Method b(A<String>) has the same erasure b(A<T>) as another method in type X\n" + 
4318
				"----------\n":
4319
					"----------\n" + 
4320
					"1. ERROR in X.java (at line 2)\n" + 
4321
					"	<N extends B> N a(A<Number> s) { return null; }\n" + 
4322
					"	                ^^^^^^^^^^^^^^\n" + 
4323
					"Duplicate method a(A<Number>) in type X\n" + 
4324
					"----------\n" + 
4325
					"2. ERROR in X.java (at line 3)\n" + 
4326
					"	<N> Object a(A<Number> n) { return null; }\n" + 
4327
					"	           ^^^^^^^^^^^^^^\n" + 
4328
					"Duplicate method a(A<Number>) in type X\n" + 
4329
					"----------\n" + 
4330
					"3. ERROR in X.java (at line 4)\n" + 
4331
					"	<N extends B> N b(A<Number> s) { return null; }\n" + 
4332
					"	                ^^^^^^^^^^^^^^\n" + 
4333
					"Method b(A<Number>) has the same erasure b(A<T>) as another method in type X\n" + 
4334
					"----------\n" + 
4335
					"4. ERROR in X.java (at line 5)\n" + 
4336
					"	<N> Object b(A<String> n) { return null; }\n" + 
4337
					"	           ^^^^^^^^^^^^^^\n" + 
4338
					"Method b(A<String>) has the same erasure b(A<T>) as another method in type X\n" + 
4339
					"----------\n";
4091
		this.runNegativeTest(
4340
		this.runNegativeTest(
4092
			new String[] {
4341
			new String[] {
4093
				"X.java",
4342
				"X.java",
Lines 4100-4126 Link Here
4100
				"class A<T> {}\n" +
4349
				"class A<T> {}\n" +
4101
				"class B {}\n"
4350
				"class B {}\n"
4102
			},
4351
			},
4103
			"----------\n" + 
4352
			expectedCompilerLog
4104
			"1. ERROR in X.java (at line 2)\n" + 
4105
			"	<N extends B> N a(A<Number> s) { return null; }\n" + 
4106
			"	                ^^^^^^^^^^^^^^\n" + 
4107
			"Duplicate method a(A<Number>) in type X\n" + 
4108
			"----------\n" + 
4109
			"2. ERROR in X.java (at line 3)\n" + 
4110
			"	<N> Object a(A<Number> n) { return null; }\n" + 
4111
			"	           ^^^^^^^^^^^^^^\n" + 
4112
			"Duplicate method a(A<Number>) in type X\n" + 
4113
			"----------\n" + 
4114
			"3. ERROR in X.java (at line 4)\n" + 
4115
			"	<N extends B> N b(A<Number> s) { return null; }\n" + 
4116
			"	                ^^^^^^^^^^^^^^\n" + 
4117
			"Method b(A<Number>) has the same erasure b(A<T>) as another method in type X\n" + 
4118
			"----------\n" + 
4119
			"4. ERROR in X.java (at line 5)\n" + 
4120
			"	<N> Object b(A<String> n) { return null; }\n" + 
4121
			"	           ^^^^^^^^^^^^^^\n" + 
4122
			"Method b(A<String>) has the same erasure b(A<T>) as another method in type X\n" + 
4123
			"----------\n"
4124
		);
4353
		);
4125
/* javac 7
4354
/* javac 7
4126
X.java:3: name clash: <N#1>a(A<Number>) and <N#2>a(A<Number>) have the same erasure
4355
X.java:3: name clash: <N#1>a(A<Number>) and <N#2>a(A<Number>) have the same erasure
Lines 4254-4279 Link Here
4254
				"class A<T> {}\n" +
4483
				"class A<T> {}\n" +
4255
				"class B {}\n"
4484
				"class B {}\n"
4256
			},
4485
			},
4257
			"----------\n" +
4486
			"----------\n" + 
4258
			"1. ERROR in X.java (at line 2)\n" +
4487
			"1. ERROR in X.java (at line 2)\n" + 
4259
			"	void a(A<Number> s) {}\n" +
4488
			"	void a(A<Number> s) {}\n" + 
4260
			"	     ^^^^^^^^^^^^^^\n" +
4489
			"	     ^^^^^^^^^^^^^^\n" + 
4261
			"Duplicate method a(A<Number>) in type X\n" +
4490
			"Duplicate method a(A<Number>) in type X\n" + 
4262
			"----------\n" +
4491
			"----------\n" + 
4263
			"2. ERROR in X.java (at line 3)\n" +
4492
			"2. ERROR in X.java (at line 3)\n" + 
4264
			"	B a(A<Number> n) { return null; }\n" +
4493
			"	B a(A<Number> n) { return null; }\n" + 
4265
			"	  ^^^^^^^^^^^^^^\n" +
4494
			"	  ^^^^^^^^^^^^^^\n" + 
4266
			"Duplicate method a(A<Number>) in type X\n" +
4495
			"Duplicate method a(A<Number>) in type X\n" + 
4267
			"----------\n" +
4496
			"----------\n" + 
4268
			"3. ERROR in X.java (at line 4)\n" +
4497
			"3. ERROR in X.java (at line 4)\n" + 
4269
			"	Object b(A<Number> s) {}\n" +
4498
			"	Object b(A<Number> s) {}\n" + 
4270
			"	       ^^^^^^^^^^^^^^\n" +
4499
			"	       ^^^^^^^^^^^^^^\n" + 
4271
			"Duplicate method b(A<Number>) in type X\n" +
4500
			"Duplicate method b(A<Number>) in type X\n" + 
4272
			"----------\n" +
4501
			"----------\n" + 
4273
			"4. ERROR in X.java (at line 5)\n" +
4502
			"4. ERROR in X.java (at line 4)\n" + 
4274
			"	B b(A<Number> n) { return null; }\n" +
4503
			"	Object b(A<Number> s) {}\n" + 
4275
			"	  ^^^^^^^^^^^^^^\n" +
4504
			"	       ^^^^^^^^^^^^^^\n" + 
4276
			"Duplicate method b(A<Number>) in type X\n" +
4505
			"This method must return a result of type Object\n" + 
4506
			"----------\n" + 
4507
			"5. ERROR in X.java (at line 5)\n" + 
4508
			"	B b(A<Number> n) { return null; }\n" + 
4509
			"	  ^^^^^^^^^^^^^^\n" + 
4510
			"Duplicate method b(A<Number>) in type X\n" + 
4277
			"----------\n"
4511
			"----------\n"
4278
		);
4512
		);
4279
/* javac 7
4513
/* javac 7
Lines 4347-4352 Link Here
4347
	}
4581
	}
4348
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=89470
4582
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=89470
4349
	public void test051b() {
4583
	public void test051b() {
4584
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
4585
				"----------\n" + 
4586
				"1. WARNING in X.java (at line 2)\n" + 
4587
				"	void foo(A<String> a) {}\n" + 
4588
				"	     ^^^^^^^^^^^^^^^^\n" + 
4589
				"Method foo(A<String>) has the same erasure foo(A<T>) as another method in type X\n" + 
4590
				"----------\n" + 
4591
				"2. WARNING in X.java (at line 3)\n" + 
4592
				"	Object foo(A<Integer> a) { return null; }\n" + 
4593
				"	       ^^^^^^^^^^^^^^^^^\n" + 
4594
				"Method foo(A<Integer>) has the same erasure foo(A<T>) as another method in type X\n" + 
4595
				"----------\n":
4596
					"----------\n" + 
4597
					"1. ERROR in X.java (at line 2)\n" + 
4598
					"	void foo(A<String> a) {}\n" + 
4599
					"	     ^^^^^^^^^^^^^^^^\n" + 
4600
					"Method foo(A<String>) has the same erasure foo(A<T>) as another method in type X\n" + 
4601
					"----------\n" + 
4602
					"2. ERROR in X.java (at line 3)\n" + 
4603
					"	Object foo(A<Integer> a) { return null; }\n" + 
4604
					"	       ^^^^^^^^^^^^^^^^^\n" + 
4605
					"Method foo(A<Integer>) has the same erasure foo(A<T>) as another method in type X\n" + 
4606
					"----------\n";
4350
		this.runNegativeTest(
4607
		this.runNegativeTest(
4351
			new String[] {
4608
			new String[] {
4352
				"X.java",
4609
				"X.java",
Lines 4356-4372 Link Here
4356
				"}\n" +
4613
				"}\n" +
4357
				"class A<T> {}\n",
4614
				"class A<T> {}\n",
4358
			},
4615
			},
4359
			"----------\n" + 
4616
			expectedCompilerLog
4360
			"1. ERROR in X.java (at line 2)\n" + 
4361
			"	void foo(A<String> a) {}\n" + 
4362
			"	     ^^^^^^^^^^^^^^^^\n" + 
4363
			"Method foo(A<String>) has the same erasure foo(A<T>) as another method in type X\n" + 
4364
			"----------\n" + 
4365
			"2. ERROR in X.java (at line 3)\n" + 
4366
			"	Object foo(A<Integer> a) { return null; }\n" + 
4367
			"	       ^^^^^^^^^^^^^^^^^\n" + 
4368
			"Method foo(A<Integer>) has the same erasure foo(A<T>) as another method in type X\n" + 
4369
			"----------\n"
4370
		);
4617
		);
4371
/* javac 7
4618
/* javac 7
4372
X.java:3: name clash: foo(A<Integer>) and foo(A<String>) have the same erasure
4619
X.java:3: name clash: foo(A<Integer>) and foo(A<String>) have the same erasure
Lines 4489-4494 Link Here
4489
4736
4490
	// more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897
4737
	// more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897
4491
	public void test054() {
4738
	public void test054() {
4739
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
4740
				"----------\n" + 
4741
				"1. WARNING in X.java (at line 2)\n" + 
4742
				"	void a(Object x) {}\n" + 
4743
				"	     ^^^^^^^^^^^\n" + 
4744
				"Method a(Object) has the same erasure a(Object) as another method in type X\n" + 
4745
				"----------\n" + 
4746
				"2. WARNING in X.java (at line 3)\n" + 
4747
				"	<T> T a(T x) {  return null; }\n" + 
4748
				"	      ^^^^^^\n" + 
4749
				"Method a(T) has the same erasure a(Object) as another method in type X\n" + 
4750
				"----------\n":
4751
					"----------\n" +
4752
					"1. ERROR in X.java (at line 2)\n" +
4753
					"	void a(Object x) {}\n" +
4754
					"	     ^^^^^^^^^^^\n" +
4755
					"Method a(Object) has the same erasure a(Object) as another method in type X\n" +
4756
					"----------\n" +
4757
					"2. ERROR in X.java (at line 3)\n" +
4758
					"	<T> T a(T x) {  return null; }\n" +
4759
					"	      ^^^^^^\n" +
4760
					"Method a(T) has the same erasure a(Object) as another method in type X\n" +
4761
					"----------\n";
4492
		this.runNegativeTest(
4762
		this.runNegativeTest(
4493
			new String[] {
4763
			new String[] {
4494
				"X.java",
4764
				"X.java",
Lines 4497-4513 Link Here
4497
				"	<T> T a(T x) {  return null; }\n" +
4767
				"	<T> T a(T x) {  return null; }\n" +
4498
				"}\n"
4768
				"}\n"
4499
			},
4769
			},
4500
			"----------\n" +
4770
			expectedCompilerLog
4501
			"1. ERROR in X.java (at line 2)\n" +
4502
			"	void a(Object x) {}\n" +
4503
			"	     ^^^^^^^^^^^\n" +
4504
			"Method a(Object) has the same erasure a(Object) as another method in type X\n" +
4505
			"----------\n" +
4506
			"2. ERROR in X.java (at line 3)\n" +
4507
			"	<T> T a(T x) {  return null; }\n" +
4508
			"	      ^^^^^^\n" +
4509
			"Method a(T) has the same erasure a(Object) as another method in type X\n" +
4510
			"----------\n"
4511
		);
4771
		);
4512
/* javac 7
4772
/* javac 7
4513
X.java:3: a(Object) is already defined in X
4773
X.java:3: a(Object) is already defined in X
Lines 4518-4523 Link Here
4518
	}
4778
	}
4519
	// more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897
4779
	// more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897
4520
	public void test054a() {
4780
	public void test054a() {
4781
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
4782
				"----------\n" + 
4783
				"1. WARNING in X.java (at line 2)\n" + 
4784
				"	<T1, T2> String aaa(X x) {  return null; }\n" + 
4785
				"	                ^^^^^^^^\n" + 
4786
				"Method aaa(X) has the same erasure aaa(X) as another method in type X\n" + 
4787
				"----------\n" + 
4788
				"2. WARNING in X.java (at line 3)\n" + 
4789
				"	<T extends X> T aaa(T x) {  return null; }\n" + 
4790
				"	                ^^^^^^^^\n" + 
4791
				"Method aaa(T) has the same erasure aaa(X) as another method in type X\n" + 
4792
				"----------\n" + 
4793
				"3. WARNING in X.java (at line 4)\n" + 
4794
				"	<T> String aa(X x) {  return null; }\n" + 
4795
				"	           ^^^^^^^\n" + 
4796
				"Method aa(X) has the same erasure aa(X) as another method in type X\n" + 
4797
				"----------\n" + 
4798
				"4. WARNING in X.java (at line 5)\n" + 
4799
				"	<T extends X> T aa(T x) {  return null; }\n" + 
4800
				"	                ^^^^^^^\n" + 
4801
				"Method aa(T) has the same erasure aa(X) as another method in type X\n" + 
4802
				"----------\n" + 
4803
				"5. WARNING in X.java (at line 6)\n" + 
4804
				"	String a(X x) {  return null; }\n" + 
4805
				"	       ^^^^^^\n" + 
4806
				"Method a(X) has the same erasure a(X) as another method in type X\n" + 
4807
				"----------\n" + 
4808
				"6. WARNING in X.java (at line 7)\n" + 
4809
				"	<T extends X> T a(T x) {  return null; }\n" + 
4810
				"	                ^^^^^^\n" + 
4811
				"Method a(T) has the same erasure a(X) as another method in type X\n" + 
4812
				"----------\n" + 
4813
				"7. WARNING in X.java (at line 8)\n" + 
4814
				"	<T> String z(X x) { return null; }\n" + 
4815
				"	           ^^^^^^\n" + 
4816
				"Duplicate method z(X) in type X\n" + 
4817
				"----------\n" + 
4818
				"8. WARNING in X.java (at line 9)\n" + 
4819
				"	<T, S> Object z(X x) { return null; }\n" + 
4820
				"	              ^^^^^^\n" + 
4821
				"Duplicate method z(X) in type X\n" + 
4822
				"----------\n":
4823
					"----------\n" + 
4824
					"1. ERROR in X.java (at line 2)\n" + 
4825
					"	<T1, T2> String aaa(X x) {  return null; }\n" + 
4826
					"	                ^^^^^^^^\n" + 
4827
					"Method aaa(X) has the same erasure aaa(X) as another method in type X\n" + 
4828
					"----------\n" + 
4829
					"2. ERROR in X.java (at line 3)\n" + 
4830
					"	<T extends X> T aaa(T x) {  return null; }\n" + 
4831
					"	                ^^^^^^^^\n" + 
4832
					"Method aaa(T) has the same erasure aaa(X) as another method in type X\n" + 
4833
					"----------\n" + 
4834
					"3. ERROR in X.java (at line 4)\n" + 
4835
					"	<T> String aa(X x) {  return null; }\n" + 
4836
					"	           ^^^^^^^\n" + 
4837
					"Method aa(X) has the same erasure aa(X) as another method in type X\n" + 
4838
					"----------\n" + 
4839
					"4. ERROR in X.java (at line 5)\n" + 
4840
					"	<T extends X> T aa(T x) {  return null; }\n" + 
4841
					"	                ^^^^^^^\n" + 
4842
					"Method aa(T) has the same erasure aa(X) as another method in type X\n" + 
4843
					"----------\n" + 
4844
					"5. ERROR in X.java (at line 6)\n" + 
4845
					"	String a(X x) {  return null; }\n" + 
4846
					"	       ^^^^^^\n" + 
4847
					"Method a(X) has the same erasure a(X) as another method in type X\n" + 
4848
					"----------\n" + 
4849
					"6. ERROR in X.java (at line 7)\n" + 
4850
					"	<T extends X> T a(T x) {  return null; }\n" + 
4851
					"	                ^^^^^^\n" + 
4852
					"Method a(T) has the same erasure a(X) as another method in type X\n" + 
4853
					"----------\n" + 
4854
					"7. ERROR in X.java (at line 8)\n" + 
4855
					"	<T> String z(X x) { return null; }\n" + 
4856
					"	           ^^^^^^\n" + 
4857
					"Duplicate method z(X) in type X\n" + 
4858
					"----------\n" + 
4859
					"8. ERROR in X.java (at line 9)\n" + 
4860
					"	<T, S> Object z(X x) { return null; }\n" + 
4861
					"	              ^^^^^^\n" + 
4862
					"Duplicate method z(X) in type X\n" + 
4863
					"----------\n";
4521
		this.runNegativeTest(
4864
		this.runNegativeTest(
4522
			new String[] {
4865
			new String[] {
4523
				"X.java",
4866
				"X.java",
Lines 4532-4578 Link Here
4532
				"	<T, S> Object z(X x) { return null; }\n" +
4875
				"	<T, S> Object z(X x) { return null; }\n" +
4533
				"}\n"
4876
				"}\n"
4534
			},
4877
			},
4535
			"----------\n" + 
4878
			expectedCompilerLog
4536
			"1. ERROR in X.java (at line 2)\n" + 
4537
			"	<T1, T2> String aaa(X x) {  return null; }\n" + 
4538
			"	                ^^^^^^^^\n" + 
4539
			"Method aaa(X) has the same erasure aaa(X) as another method in type X\n" + 
4540
			"----------\n" + 
4541
			"2. ERROR in X.java (at line 3)\n" + 
4542
			"	<T extends X> T aaa(T x) {  return null; }\n" + 
4543
			"	                ^^^^^^^^\n" + 
4544
			"Method aaa(T) has the same erasure aaa(X) as another method in type X\n" + 
4545
			"----------\n" + 
4546
			"3. ERROR in X.java (at line 4)\n" + 
4547
			"	<T> String aa(X x) {  return null; }\n" + 
4548
			"	           ^^^^^^^\n" + 
4549
			"Method aa(X) has the same erasure aa(X) as another method in type X\n" + 
4550
			"----------\n" + 
4551
			"4. ERROR in X.java (at line 5)\n" + 
4552
			"	<T extends X> T aa(T x) {  return null; }\n" + 
4553
			"	                ^^^^^^^\n" + 
4554
			"Method aa(T) has the same erasure aa(X) as another method in type X\n" + 
4555
			"----------\n" + 
4556
			"5. ERROR in X.java (at line 6)\n" + 
4557
			"	String a(X x) {  return null; }\n" + 
4558
			"	       ^^^^^^\n" + 
4559
			"Method a(X) has the same erasure a(X) as another method in type X\n" + 
4560
			"----------\n" + 
4561
			"6. ERROR in X.java (at line 7)\n" + 
4562
			"	<T extends X> T a(T x) {  return null; }\n" + 
4563
			"	                ^^^^^^\n" + 
4564
			"Method a(T) has the same erasure a(X) as another method in type X\n" + 
4565
			"----------\n" + 
4566
			"7. ERROR in X.java (at line 8)\n" + 
4567
			"	<T> String z(X x) { return null; }\n" + 
4568
			"	           ^^^^^^\n" + 
4569
			"Duplicate method z(X) in type X\n" + 
4570
			"----------\n" + 
4571
			"8. ERROR in X.java (at line 9)\n" + 
4572
			"	<T, S> Object z(X x) { return null; }\n" + 
4573
			"	              ^^^^^^\n" + 
4574
			"Duplicate method z(X) in type X\n" + 
4575
			"----------\n"
4576
		);
4879
		);
4577
/* javac 7
4880
/* javac 7
4578
X.java:3: name clash: <T>aaa(T) and <T1,T2>aaa(X) have the same erasure
4881
X.java:3: name clash: <T>aaa(T) and <T1,T2>aaa(X) have the same erasure
Lines 4603-4608 Link Here
4603
	}
4906
	}
4604
	// more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897
4907
	// more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897
4605
	public void test054b() {
4908
	public void test054b() {
4909
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
4910
				"----------\n" + 
4911
				"1. WARNING in X.java (at line 2)\n" + 
4912
				"	Object foo(X<T> t) { return null; }\n" + 
4913
				"	       ^^^^^^^^^^^\n" + 
4914
				"Duplicate method foo(X<T>) in type X<T>\n" + 
4915
				"----------\n" + 
4916
				"2. WARNING in X.java (at line 3)\n" + 
4917
				"	<S> String foo(X<T> s) { return null; }\n" + 
4918
				"	           ^^^^^^^^^^^\n" + 
4919
				"Duplicate method foo(X<T>) in type X<T>\n" + 
4920
				"----------\n":
4921
					"----------\n" + 
4922
					"1. ERROR in X.java (at line 2)\n" + 
4923
					"	Object foo(X<T> t) { return null; }\n" + 
4924
					"	       ^^^^^^^^^^^\n" + 
4925
					"Duplicate method foo(X<T>) in type X<T>\n" + 
4926
					"----------\n" + 
4927
					"2. ERROR in X.java (at line 3)\n" + 
4928
					"	<S> String foo(X<T> s) { return null; }\n" + 
4929
					"	           ^^^^^^^^^^^\n" + 
4930
					"Duplicate method foo(X<T>) in type X<T>\n" + 
4931
					"----------\n";
4606
		this.runNegativeTest(
4932
		this.runNegativeTest(
4607
			new String[] {
4933
			new String[] {
4608
				"X.java",
4934
				"X.java",
Lines 4611-4627 Link Here
4611
				"		 <S> String foo(X<T> s) { return null; }\n" +
4937
				"		 <S> String foo(X<T> s) { return null; }\n" +
4612
				"}\n"
4938
				"}\n"
4613
			},
4939
			},
4614
			"----------\n" + 
4940
			expectedCompilerLog
4615
			"1. ERROR in X.java (at line 2)\n" + 
4616
			"	Object foo(X<T> t) { return null; }\n" + 
4617
			"	       ^^^^^^^^^^^\n" + 
4618
			"Duplicate method foo(X<T>) in type X<T>\n" + 
4619
			"----------\n" + 
4620
			"2. ERROR in X.java (at line 3)\n" + 
4621
			"	<S> String foo(X<T> s) { return null; }\n" + 
4622
			"	           ^^^^^^^^^^^\n" + 
4623
			"Duplicate method foo(X<T>) in type X<T>\n" + 
4624
			"----------\n"
4625
		);
4941
		);
4626
/* javac 7
4942
/* javac 7
4627
X.java:3: name clash: <S>foo(X<T>) and foo(X<T>) have the same erasure
4943
X.java:3: name clash: <S>foo(X<T>) and foo(X<T>) have the same erasure
Lines 4666-4671 Link Here
4666
	}
4982
	}
4667
	// more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897
4983
	// more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897
4668
	public void test054d() {
4984
	public void test054d() {
4985
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
4986
				"----------\n" + 
4987
				"1. WARNING in X.java (at line 2)\n" + 
4988
				"	<T> T a(A<T> t) {return null;}\n" + 
4989
				"	      ^^^^^^^^^\n" + 
4990
				"Method a(A<T>) has the same erasure a(A<T>) as another method in type X\n" + 
4991
				"----------\n" + 
4992
				"2. WARNING in X.java (at line 3)\n" + 
4993
				"	<T> String a(A<Object> o) {return null;}\n" + 
4994
				"	           ^^^^^^^^^^^^^^\n" + 
4995
				"Method a(A<Object>) has the same erasure a(A<T>) as another method in type X\n" + 
4996
				"----------\n" + 
4997
				"3. WARNING in X.java (at line 4)\n" + 
4998
				"	<T> T aa(A<T> t) {return null;}\n" + 
4999
				"	      ^^^^^^^^^^\n" + 
5000
				"Method aa(A<T>) has the same erasure aa(A<T>) as another method in type X\n" + 
5001
				"----------\n" + 
5002
				"4. WARNING in X.java (at line 5)\n" + 
5003
				"	String aa(A<Object> o) {return null;}\n" + 
5004
				"	       ^^^^^^^^^^^^^^^\n" + 
5005
				"Method aa(A<Object>) has the same erasure aa(A<T>) as another method in type X\n" + 
5006
				"----------\n":
5007
					"----------\n" + 
5008
					"1. ERROR in X.java (at line 2)\n" + 
5009
					"	<T> T a(A<T> t) {return null;}\n" + 
5010
					"	      ^^^^^^^^^\n" + 
5011
					"Method a(A<T>) has the same erasure a(A<T>) as another method in type X\n" + 
5012
					"----------\n" + 
5013
					"2. ERROR in X.java (at line 3)\n" + 
5014
					"	<T> String a(A<Object> o) {return null;}\n" + 
5015
					"	           ^^^^^^^^^^^^^^\n" + 
5016
					"Method a(A<Object>) has the same erasure a(A<T>) as another method in type X\n" + 
5017
					"----------\n" + 
5018
					"3. ERROR in X.java (at line 4)\n" + 
5019
					"	<T> T aa(A<T> t) {return null;}\n" + 
5020
					"	      ^^^^^^^^^^\n" + 
5021
					"Method aa(A<T>) has the same erasure aa(A<T>) as another method in type X\n" + 
5022
					"----------\n" + 
5023
					"4. ERROR in X.java (at line 5)\n" + 
5024
					"	String aa(A<Object> o) {return null;}\n" + 
5025
					"	       ^^^^^^^^^^^^^^^\n" + 
5026
					"Method aa(A<Object>) has the same erasure aa(A<T>) as another method in type X\n" + 
5027
					"----------\n";
4669
		this.runNegativeTest(
5028
		this.runNegativeTest(
4670
			new String[] {
5029
			new String[] {
4671
				"X.java",
5030
				"X.java",
Lines 4677-4703 Link Here
4677
				"}\n" +
5036
				"}\n" +
4678
				"class A<T> {}\n",
5037
				"class A<T> {}\n",
4679
			},
5038
			},
4680
			"----------\n" + 
5039
			expectedCompilerLog
4681
			"1. ERROR in X.java (at line 2)\n" + 
4682
			"	<T> T a(A<T> t) {return null;}\n" + 
4683
			"	      ^^^^^^^^^\n" + 
4684
			"Method a(A<T>) has the same erasure a(A<T>) as another method in type X\n" + 
4685
			"----------\n" + 
4686
			"2. ERROR in X.java (at line 3)\n" + 
4687
			"	<T> String a(A<Object> o) {return null;}\n" + 
4688
			"	           ^^^^^^^^^^^^^^\n" + 
4689
			"Method a(A<Object>) has the same erasure a(A<T>) as another method in type X\n" + 
4690
			"----------\n" + 
4691
			"3. ERROR in X.java (at line 4)\n" + 
4692
			"	<T> T aa(A<T> t) {return null;}\n" + 
4693
			"	      ^^^^^^^^^^\n" + 
4694
			"Method aa(A<T>) has the same erasure aa(A<T>) as another method in type X\n" + 
4695
			"----------\n" + 
4696
			"4. ERROR in X.java (at line 5)\n" + 
4697
			"	String aa(A<Object> o) {return null;}\n" + 
4698
			"	       ^^^^^^^^^^^^^^^\n" + 
4699
			"Method aa(A<Object>) has the same erasure aa(A<T>) as another method in type X\n" + 
4700
			"----------\n"
4701
		);
5040
		);
4702
/* javac 7
5041
/* javac 7
4703
X.java:3: name clash: <T#1>a(A<Object>) and <T#2>a(A<T#2>) have the same erasure
5042
X.java:3: name clash: <T#1>a(A<Object>) and <T#2>a(A<T#2>) have the same erasure
Lines 4821-4826 Link Here
4821
	}
5160
	}
4822
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=94898
5161
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=94898
4823
	public void test058a() {
5162
	public void test058a() {
5163
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
5164
				"----------\n" + 
5165
				"1. ERROR in X.java (at line 3)\n" + 
5166
				"	new X<Object>().foo(\"X\");\n" + 
5167
				"	                ^^^\n" + 
5168
				"The method foo(String) is ambiguous for the type X<Object>\n" + 
5169
				"----------\n" + 
5170
				"2. ERROR in X.java (at line 4)\n" + 
5171
				"	new X<Object>().foo2(\"X\");\n" + 
5172
				"	                ^^^^\n" + 
5173
				"The method foo2(String) is ambiguous for the type X<Object>\n" + 
5174
				"----------\n" + 
5175
				"3. WARNING in X.java (at line 6)\n" + 
5176
				"	<T> T foo(T t) {return null;}\n" + 
5177
				"	      ^^^^^^^^\n" + 
5178
				"Method foo(T) has the same erasure foo(Object) as another method in type X<A>\n" + 
5179
				"----------\n" + 
5180
				"4. WARNING in X.java (at line 7)\n" + 
5181
				"	void foo(A a) {}\n" + 
5182
				"	     ^^^^^^^^\n" + 
5183
				"Method foo(A) has the same erasure foo(Object) as another method in type X<A>\n" + 
5184
				"----------\n" + 
5185
				"5. WARNING in X.java (at line 8)\n" + 
5186
				"	<T> T foo2(T t) {return null;}\n" + 
5187
				"	      ^^^^^^^^^\n" + 
5188
				"Method foo2(T) has the same erasure foo2(Object) as another method in type X<A>\n" + 
5189
				"----------\n" + 
5190
				"6. WARNING in X.java (at line 9)\n" + 
5191
				"	<T> void foo2(A a) {}\n" + 
5192
				"	         ^^^^^^^^^\n" + 
5193
				"Method foo2(A) has the same erasure foo2(Object) as another method in type X<A>\n" + 
5194
				"----------\n":
5195
					"----------\n" + 
5196
					"1. ERROR in X.java (at line 6)\n" + 
5197
					"	<T> T foo(T t) {return null;}\n" + 
5198
					"	      ^^^^^^^^\n" + 
5199
					"Method foo(T) has the same erasure foo(Object) as another method in type X<A>\n" + 
5200
					"----------\n" + 
5201
					"2. ERROR in X.java (at line 7)\n" + 
5202
					"	void foo(A a) {}\n" + 
5203
					"	     ^^^^^^^^\n" + 
5204
					"Method foo(A) has the same erasure foo(Object) as another method in type X<A>\n" + 
5205
					"----------\n" + 
5206
					"3. ERROR in X.java (at line 8)\n" + 
5207
					"	<T> T foo2(T t) {return null;}\n" + 
5208
					"	      ^^^^^^^^^\n" + 
5209
					"Method foo2(T) has the same erasure foo2(Object) as another method in type X<A>\n" + 
5210
					"----------\n" + 
5211
					"4. ERROR in X.java (at line 9)\n" + 
5212
					"	<T> void foo2(A a) {}\n" + 
5213
					"	         ^^^^^^^^^\n" + 
5214
					"Method foo2(A) has the same erasure foo2(Object) as another method in type X<A>\n" + 
5215
					"----------\n";
4824
		this.runNegativeTest(
5216
		this.runNegativeTest(
4825
			new String[] {
5217
			new String[] {
4826
				"X.java",
5218
				"X.java",
Lines 4835-4861 Link Here
4835
				"	<T> void foo2(A a) {}\n" +
5227
				"	<T> void foo2(A a) {}\n" +
4836
				"}\n"
5228
				"}\n"
4837
			},
5229
			},
4838
			"----------\n" + 
5230
			expectedCompilerLog
4839
			"1. ERROR in X.java (at line 6)\n" + 
4840
			"	<T> T foo(T t) {return null;}\n" + 
4841
			"	      ^^^^^^^^\n" + 
4842
			"Method foo(T) has the same erasure foo(Object) as another method in type X<A>\n" + 
4843
			"----------\n" + 
4844
			"2. ERROR in X.java (at line 7)\n" + 
4845
			"	void foo(A a) {}\n" + 
4846
			"	     ^^^^^^^^\n" + 
4847
			"Method foo(A) has the same erasure foo(Object) as another method in type X<A>\n" + 
4848
			"----------\n" + 
4849
			"3. ERROR in X.java (at line 8)\n" + 
4850
			"	<T> T foo2(T t) {return null;}\n" + 
4851
			"	      ^^^^^^^^^\n" + 
4852
			"Method foo2(T) has the same erasure foo2(Object) as another method in type X<A>\n" + 
4853
			"----------\n" + 
4854
			"4. ERROR in X.java (at line 9)\n" + 
4855
			"	<T> void foo2(A a) {}\n" + 
4856
			"	         ^^^^^^^^^\n" + 
4857
			"Method foo2(A) has the same erasure foo2(Object) as another method in type X<A>\n" + 
4858
			"----------\n"
4859
		);
5231
		);
4860
/* javac 7
5232
/* javac 7
4861
X.java:7: name clash: foo(A) and <T>foo(T) have the same erasure
5233
X.java:7: name clash: foo(A) and <T>foo(T) have the same erasure
Lines 4876-4881 Link Here
4876
	}
5248
	}
4877
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=94898
5249
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=94898
4878
	public void test058b() {
5250
	public void test058b() {
5251
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
5252
				"----------\n" + 
5253
				"1. ERROR in X.java (at line 3)\n" + 
5254
				"	new X<Object>().foo(\"X\");\n" + 
5255
				"	                ^^^\n" + 
5256
				"The method foo(String) is ambiguous for the type X<Object>\n" + 
5257
				"----------\n" + 
5258
				"2. ERROR in X.java (at line 4)\n" + 
5259
				"	new X<Object>().foo2(\"X\");\n" + 
5260
				"	                ^^^^\n" + 
5261
				"The method foo2(String) is ambiguous for the type X<Object>\n" + 
5262
				"----------\n" + 
5263
				"3. WARNING in X.java (at line 6)\n" + 
5264
				"	<T> T foo(T t) {return null;}\n" + 
5265
				"	      ^^^^^^^^\n" + 
5266
				"Name clash: The method foo(T) of type X<A> has the same erasure as foo(A) of type Y<A> but does not override it\n" + 
5267
				"----------\n" + 
5268
				"4. WARNING in X.java (at line 7)\n" + 
5269
				"	<T> T foo2(T t) {return null;}\n" + 
5270
				"	      ^^^^^^^^^\n" + 
5271
				"Name clash: The method foo2(T) of type X<A> has the same erasure as foo2(A) of type Y<A> but does not override it\n" + 
5272
				"----------\n":
5273
					"----------\n" +
5274
					"1. ERROR in X.java (at line 3)\n" + 
5275
					"	new X<Object>().foo(\"X\");\n" + 
5276
					"	                ^^^\n" + 
5277
					"The method foo(String) is ambiguous for the type X<Object>\n" + 
5278
					"----------\n" + 
5279
					"2. ERROR in X.java (at line 4)\n" + 
5280
					"	new X<Object>().foo2(\"X\");\n" + 
5281
					"	                ^^^^\n" + 
5282
					"The method foo2(String) is ambiguous for the type X<Object>\n" + 
5283
					"----------\n" + 
5284
					"3. ERROR in X.java (at line 6)\n" + 
5285
					"	<T> T foo(T t) {return null;}\n" + 
5286
					"	      ^^^^^^^^\n" + 
5287
					"Name clash: The method foo(T) of type X<A> has the same erasure as foo(A) of type Y<A> but does not override it\n" + 
5288
					"----------\n" + 
5289
					"4. ERROR in X.java (at line 7)\n" + 
5290
					"	<T> T foo2(T t) {return null;}\n" + 
5291
					"	      ^^^^^^^^^\n" + 
5292
					"Name clash: The method foo2(T) of type X<A> has the same erasure as foo2(A) of type Y<A> but does not override it\n" + 
5293
					"----------\n";
4879
		this.runNegativeTest(
5294
		this.runNegativeTest(
4880
			new String[] {
5295
			new String[] {
4881
				"X.java",
5296
				"X.java",
Lines 4892-4918 Link Here
4892
				"	<T> void foo2(A a) {}\n" +
5307
				"	<T> void foo2(A a) {}\n" +
4893
				"}"
5308
				"}"
4894
			},
5309
			},
4895
			"----------\n" +
5310
			expectedCompilerLog
4896
			"1. ERROR in X.java (at line 3)\n" + 
4897
			"	new X<Object>().foo(\"X\");\n" + 
4898
			"	                ^^^\n" + 
4899
			"The method foo(String) is ambiguous for the type X<Object>\n" + 
4900
			"----------\n" + 
4901
			"2. ERROR in X.java (at line 4)\n" + 
4902
			"	new X<Object>().foo2(\"X\");\n" + 
4903
			"	                ^^^^\n" + 
4904
			"The method foo2(String) is ambiguous for the type X<Object>\n" + 
4905
			"----------\n" + 
4906
			"3. ERROR in X.java (at line 6)\n" + 
4907
			"	<T> T foo(T t) {return null;}\n" + 
4908
			"	      ^^^^^^^^\n" + 
4909
			"Name clash: The method foo(T) of type X<A> has the same erasure as foo(A) of type Y<A> but does not override it\n" + 
4910
			"----------\n" + 
4911
			"4. ERROR in X.java (at line 7)\n" + 
4912
			"	<T> T foo2(T t) {return null;}\n" + 
4913
			"	      ^^^^^^^^^\n" + 
4914
			"Name clash: The method foo2(T) of type X<A> has the same erasure as foo2(A) of type Y<A> but does not override it\n" + 
4915
			"----------\n"
4916
		);
5311
		);
4917
/* javac 7
5312
/* javac 7
4918
X.java:3: reference to foo is ambiguous, both method foo(A) in Y and method <T>foo(T) in X match
5313
X.java:3: reference to foo is ambiguous, both method foo(A) in Y and method <T>foo(T) in X match
Lines 7971-7976 Link Here
7971
}
8366
}
7972
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=202830
8367
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=202830
7973
public void test120a() {
8368
public void test120a() {
8369
	String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
8370
			"----------\n" + 
8371
			"1. WARNING in Bar.java (at line 2)\n" + 
8372
			"	int getThing(V v) { return 1; }\n" + 
8373
			"	    ^^^^^^^^^^^^^\n" + 
8374
			"Method getThing(V) has the same erasure getThing(Object) as another method in type Foo<V,E>\n" + 
8375
			"----------\n" + 
8376
			"2. WARNING in Bar.java (at line 3)\n" + 
8377
			"	boolean getThing(E e) { return true; }\n" + 
8378
			"	        ^^^^^^^^^^^^^\n" + 
8379
			"Method getThing(E) has the same erasure getThing(Object) as another method in type Foo<V,E>\n" + 
8380
			"----------\n":
8381
				"----------\n" + 
8382
				"1. ERROR in Bar.java (at line 2)\n" + 
8383
				"	int getThing(V v) { return 1; }\n" + 
8384
				"	    ^^^^^^^^^^^^^\n" + 
8385
				"Method getThing(V) has the same erasure getThing(Object) as another method in type Foo<V,E>\n" + 
8386
				"----------\n" + 
8387
				"2. ERROR in Bar.java (at line 3)\n" + 
8388
				"	boolean getThing(E e) { return true; }\n" + 
8389
				"	        ^^^^^^^^^^^^^\n" + 
8390
				"Method getThing(E) has the same erasure getThing(Object) as another method in type Foo<V,E>\n" + 
8391
				"----------\n";
7974
	this.runNegativeTest(
8392
	this.runNegativeTest(
7975
		new String[] {
8393
		new String[] {
7976
			"Bar.java",
8394
			"Bar.java",
Lines 7980-7996 Link Here
7980
			"}\n" +
8398
			"}\n" +
7981
			"public class Bar<V,E> extends Foo<V,E> {}"
8399
			"public class Bar<V,E> extends Foo<V,E> {}"
7982
		},
8400
		},
7983
		"----------\n" + 
8401
		expectedCompilerLog
7984
		"1. ERROR in Bar.java (at line 2)\n" + 
7985
		"	int getThing(V v) { return 1; }\n" + 
7986
		"	    ^^^^^^^^^^^^^\n" + 
7987
		"Method getThing(V) has the same erasure getThing(Object) as another method in type Foo<V,E>\n" + 
7988
		"----------\n" + 
7989
		"2. ERROR in Bar.java (at line 3)\n" + 
7990
		"	boolean getThing(E e) { return true; }\n" + 
7991
		"	        ^^^^^^^^^^^^^\n" + 
7992
		"Method getThing(E) has the same erasure getThing(Object) as another method in type Foo<V,E>\n" + 
7993
		"----------\n"
7994
	);
8402
	);
7995
}
8403
}
7996
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=173477
8404
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=173477
Lines 9700-9705 Link Here
9700
// JDK7 (7b100) behavior. (earlier we would issue an extra name clash)
10108
// JDK7 (7b100) behavior. (earlier we would issue an extra name clash)
9701
public void test177() {
10109
public void test177() {
9702
	if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_6) { // see test187()
10110
	if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_6) { // see test187()
10111
		String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6)?
10112
				"----------\n" + 
10113
				"1. WARNING in X.java (at line 3)\n" + 
10114
				"	class A extends LinkedHashMap {\n" + 
10115
				"	      ^\n" + 
10116
				"The serializable class A does not declare a static final serialVersionUID field of type long\n" + 
10117
				"----------\n" + 
10118
				"2. WARNING in X.java (at line 3)\n" + 
10119
				"	class A extends LinkedHashMap {\n" + 
10120
				"	                ^^^^^^^^^^^^^\n" + 
10121
				"LinkedHashMap is a raw type. References to generic type LinkedHashMap<K,V> should be parameterized\n" + 
10122
				"----------\n" + 
10123
				"3. WARNING in X.java (at line 4)\n" + 
10124
				"	public A foo(Collection c) { return this; }\n" + 
10125
				"	             ^^^^^^^^^^\n" + 
10126
				"Collection is a raw type. References to generic type Collection<E> should be parameterized\n" + 
10127
				"----------\n" + 
10128
				"4. WARNING in X.java (at line 6)\n" + 
10129
				"	class X extends A implements I {\n" + 
10130
				"	      ^\n" + 
10131
				"The serializable class X does not declare a static final serialVersionUID field of type long\n" + 
10132
				"----------\n" + 
10133
				"5. WARNING in X.java (at line 7)\n" + 
10134
				"	@Override public X foo(Collection<?> c) { return this; }\n" + 
10135
				"	                   ^^^^^^^^^^^^^^^^^^^^\n" + 
10136
				"Name clash: The method foo(Collection<?>) of type X has the same erasure as foo(Collection) of type A but does not override it\n" + 
10137
				"----------\n":
10138
					"----------\n" + 
10139
					"1. WARNING in X.java (at line 3)\n" + 
10140
					"	class A extends LinkedHashMap {\n" + 
10141
					"	      ^\n" + 
10142
					"The serializable class A does not declare a static final serialVersionUID field of type long\n" + 
10143
					"----------\n" + 
10144
					"2. WARNING in X.java (at line 3)\n" + 
10145
					"	class A extends LinkedHashMap {\n" + 
10146
					"	                ^^^^^^^^^^^^^\n" + 
10147
					"LinkedHashMap is a raw type. References to generic type LinkedHashMap<K,V> should be parameterized\n" + 
10148
					"----------\n" + 
10149
					"3. WARNING in X.java (at line 4)\n" + 
10150
					"	public A foo(Collection c) { return this; }\n" + 
10151
					"	             ^^^^^^^^^^\n" + 
10152
					"Collection is a raw type. References to generic type Collection<E> should be parameterized\n" + 
10153
					"----------\n" + 
10154
					"4. WARNING in X.java (at line 6)\n" + 
10155
					"	class X extends A implements I {\n" + 
10156
					"	      ^\n" + 
10157
					"The serializable class X does not declare a static final serialVersionUID field of type long\n" + 
10158
					"----------\n" + 
10159
					"5. ERROR in X.java (at line 7)\n" + 
10160
					"	@Override public X foo(Collection<?> c) { return this; }\n" + 
10161
					"	                   ^^^^^^^^^^^^^^^^^^^^\n" + 
10162
					"Name clash: The method foo(Collection<?>) of type X has the same erasure as foo(Collection) of type A but does not override it\n" + 
10163
					"----------\n";
9703
		this.runNegativeTest(
10164
		this.runNegativeTest(
9704
			new String[] {
10165
			new String[] {
9705
				"X.java",
10166
				"X.java",
Lines 9712-9743 Link Here
9712
				"	@Override public X foo(Collection<?> c) { return this; }\n" +
10173
				"	@Override public X foo(Collection<?> c) { return this; }\n" +
9713
				"}"
10174
				"}"
9714
			},
10175
			},
9715
			"----------\n" + 
10176
			expectedCompilerLog
9716
			"1. WARNING in X.java (at line 3)\n" + 
9717
			"	class A extends LinkedHashMap {\n" + 
9718
			"	      ^\n" + 
9719
			"The serializable class A does not declare a static final serialVersionUID field of type long\n" + 
9720
			"----------\n" + 
9721
			"2. WARNING in X.java (at line 3)\n" + 
9722
			"	class A extends LinkedHashMap {\n" + 
9723
			"	                ^^^^^^^^^^^^^\n" + 
9724
			"LinkedHashMap is a raw type. References to generic type LinkedHashMap<K,V> should be parameterized\n" + 
9725
			"----------\n" + 
9726
			"3. WARNING in X.java (at line 4)\n" + 
9727
			"	public A foo(Collection c) { return this; }\n" + 
9728
			"	             ^^^^^^^^^^\n" + 
9729
			"Collection is a raw type. References to generic type Collection<E> should be parameterized\n" + 
9730
			"----------\n" + 
9731
			"4. WARNING in X.java (at line 6)\n" + 
9732
			"	class X extends A implements I {\n" + 
9733
			"	      ^\n" + 
9734
			"The serializable class X does not declare a static final serialVersionUID field of type long\n" + 
9735
			"----------\n" + 
9736
			"5. ERROR in X.java (at line 7)\n" + 
9737
			"	@Override public X foo(Collection<?> c) { return this; }\n" + 
9738
			"	                   ^^^^^^^^^^^^^^^^^^^^\n" + 
9739
			"Name clash: The method foo(Collection<?>) of type X has the same erasure as foo(Collection) of type A but does not override it\n" + 
9740
			"----------\n"
9741
		);
10177
		);
9742
	} else {
10178
	} else {
9743
		this.runNegativeTest(
10179
		this.runNegativeTest(
Lines 9777-9783 Link Here
9777
			"	@Override public X foo(Collection<?> c) { return this; }\n" + 
10213
			"	@Override public X foo(Collection<?> c) { return this; }\n" + 
9778
			"	                   ^^^^^^^^^^^^^^^^^^^^\n" + 
10214
			"	                   ^^^^^^^^^^^^^^^^^^^^\n" + 
9779
			"Name clash: The method foo(Collection<?>) of type X has the same erasure as foo(Collection) of type A but does not override it\n" + 
10215
			"Name clash: The method foo(Collection<?>) of type X has the same erasure as foo(Collection) of type A but does not override it\n" + 
9780
			"----------\n" + 
10216
			"----------\n" +
9781
			"6. ERROR in X.java (at line 7)\n" + 
10217
			"6. ERROR in X.java (at line 7)\n" + 
9782
			"	@Override public X foo(Collection<?> c) { return this; }\n" + 
10218
			"	@Override public X foo(Collection<?> c) { return this; }\n" + 
9783
			"	                   ^^^^^^^^^^^^^^^^^^^^\n" + 
10219
			"	                   ^^^^^^^^^^^^^^^^^^^^\n" + 
Lines 10246-10251 Link Here
10246
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
10682
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
10247
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=?
10683
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=?
10248
public void test187() {
10684
public void test187() {
10685
	String expectedCompilerLog = (this.complianceLevel == ClassFileConstants.JDK1_6 )?
10686
			"----------\n" + 
10687
			"1. WARNING in X.java (at line 6)\n" + 
10688
			"	double f(List<Integer> l) {return 0;}\n" + 
10689
			"	       ^^^^^^^^^^^^^^^^^^\n" + 
10690
			"Name clash: The method f(List<Integer>) of type Y has the same erasure as f(List<String>) of type X but does not override it\n" + 
10691
			"----------\n" + 
10692
			"2. WARNING in X.java (at line 13)\n" + 
10693
			"	int f(List<String> l) {return 0;}\n" + 
10694
			"	    ^^^^^^^^^^^^^^^^^\n" + 
10695
			"Method f(List<String>) has the same erasure f(List<E>) as another method in type XX\n" + 
10696
			"----------\n" + 
10697
			"3. WARNING in X.java (at line 14)\n" + 
10698
			"	double f(List<Integer> l) {return 0;}\n" + 
10699
			"	       ^^^^^^^^^^^^^^^^^^\n" + 
10700
			"Method f(List<Integer>) has the same erasure f(List<E>) as another method in type XX\n" + 
10701
			"----------\n":
10702
				"----------\n" + 
10703
				"1. ERROR in X.java (at line 6)\n" + 
10704
				"	double f(List<Integer> l) {return 0;}\n" + 
10705
				"	       ^^^^^^^^^^^^^^^^^^\n" + 
10706
				"Name clash: The method f(List<Integer>) of type Y has the same erasure as f(List<String>) of type X but does not override it\n" + 
10707
				"----------\n" + 
10708
				"2. ERROR in X.java (at line 13)\n" + 
10709
				"	int f(List<String> l) {return 0;}\n" + 
10710
				"	    ^^^^^^^^^^^^^^^^^\n" + 
10711
				"Method f(List<String>) has the same erasure f(List<E>) as another method in type XX\n" + 
10712
				"----------\n" + 
10713
				"3. ERROR in X.java (at line 14)\n" + 
10714
				"	double f(List<Integer> l) {return 0;}\n" + 
10715
				"	       ^^^^^^^^^^^^^^^^^^\n" + 
10716
				"Method f(List<Integer>) has the same erasure f(List<E>) as another method in type XX\n" + 
10717
				"----------\n";
10249
	this.runNegativeTest(
10718
	this.runNegativeTest(
10250
		new String[] {
10719
		new String[] {
10251
			"X.java",
10720
			"X.java",
Lines 10265-10286 Link Here
10265
    			"double f(List<Integer> l) {return 0;}\n" +// name clash in 1.5 & 7
10734
    			"double f(List<Integer> l) {return 0;}\n" +// name clash in 1.5 & 7
10266
			"}"
10735
			"}"
10267
		},
10736
		},
10268
		"----------\n" + 
10737
		expectedCompilerLog
10269
		"1. ERROR in X.java (at line 6)\n" + 
10270
		"	double f(List<Integer> l) {return 0;}\n" + 
10271
		"	       ^^^^^^^^^^^^^^^^^^\n" + 
10272
		"Name clash: The method f(List<Integer>) of type Y has the same erasure as f(List<String>) of type X but does not override it\n" + 
10273
		"----------\n" + 
10274
		"2. ERROR in X.java (at line 13)\n" + 
10275
		"	int f(List<String> l) {return 0;}\n" + 
10276
		"	    ^^^^^^^^^^^^^^^^^\n" + 
10277
		"Method f(List<String>) has the same erasure f(List<E>) as another method in type XX\n" + 
10278
		"----------\n" + 
10279
		"3. ERROR in X.java (at line 14)\n" + 
10280
		"	double f(List<Integer> l) {return 0;}\n" + 
10281
		"	       ^^^^^^^^^^^^^^^^^^\n" + 
10282
		"Method f(List<Integer>) has the same erasure f(List<E>) as another method in type XX\n" + 
10283
		"----------\n"
10284
	);
10738
	);
10285
}
10739
}
10286
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=279836
10740
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=279836
Lines 10702-10707 Link Here
10702
}
11156
}
10703
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=285088
11157
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=285088
10704
public void test200() {
11158
public void test200() {
11159
	Map options = getCompilerOptions();
11160
	String compliance = (String) options.get(JavaCore.COMPILER_COMPLIANCE);
11161
	String errorMessage = compliance == JavaCore.VERSION_1_6 ?
11162
			"----------\n" + 
11163
			"1. WARNING in X.java (at line 3)\n" + 
11164
			"	int foo(Collection bar) { return 0; }\n" + 
11165
			"	    ^^^^^^^^^^^^^^^^^^^\n" + 
11166
			"Method foo(Collection) has the same erasure foo(Collection<E>) as another method in type X\n" + 
11167
			"----------\n" + 
11168
			"2. WARNING in X.java (at line 3)\n" + 
11169
			"	int foo(Collection bar) { return 0; }\n" + 
11170
			"	        ^^^^^^^^^^\n" + 
11171
			"Collection is a raw type. References to generic type Collection<E> should be parameterized\n" + 
11172
			"----------\n" + 
11173
			"3. WARNING in X.java (at line 4)\n" + 
11174
			"	double foo(Collection<String> bar) {return 0; }\n" + 
11175
			"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
11176
			"Method foo(Collection<String>) has the same erasure foo(Collection<E>) as another method in type X\n" + 
11177
			"----------\n" :
11178
				"----------\n" + 
11179
				"1. ERROR in X.java (at line 3)\n" + 
11180
				"	int foo(Collection bar) { return 0; }\n" + 
11181
				"	    ^^^^^^^^^^^^^^^^^^^\n" + 
11182
				"Method foo(Collection) has the same erasure foo(Collection<E>) as another method in type X\n" + 
11183
				"----------\n" + 
11184
				"2. WARNING in X.java (at line 3)\n" + 
11185
				"	int foo(Collection bar) { return 0; }\n" + 
11186
				"	        ^^^^^^^^^^\n" + 
11187
				"Collection is a raw type. References to generic type Collection<E> should be parameterized\n" + 
11188
				"----------\n" + 
11189
				"3. ERROR in X.java (at line 4)\n" + 
11190
				"	double foo(Collection<String> bar) {return 0; }\n" + 
11191
				"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
11192
				"Method foo(Collection<String>) has the same erasure foo(Collection<E>) as another method in type X\n" + 
11193
				"----------\n";
10705
	this.runNegativeTest(
11194
	this.runNegativeTest(
10706
		new String[] {
11195
		new String[] {
10707
			"X.java",
11196
			"X.java",
Lines 10711-10732 Link Here
10711
			"	double foo(Collection<String> bar) {return 0; }\n" +
11200
			"	double foo(Collection<String> bar) {return 0; }\n" +
10712
			"}"
11201
			"}"
10713
		},
11202
		},
10714
		"----------\n" + 
11203
		errorMessage
10715
		"1. ERROR in X.java (at line 3)\n" + 
10716
		"	int foo(Collection bar) { return 0; }\n" + 
10717
		"	    ^^^^^^^^^^^^^^^^^^^\n" + 
10718
		"Method foo(Collection) has the same erasure foo(Collection<E>) as another method in type X\n" + 
10719
		"----------\n" + 
10720
		"2. WARNING in X.java (at line 3)\n" + 
10721
		"	int foo(Collection bar) { return 0; }\n" + 
10722
		"	        ^^^^^^^^^^\n" + 
10723
		"Collection is a raw type. References to generic type Collection<E> should be parameterized\n" + 
10724
		"----------\n" + 
10725
		"3. ERROR in X.java (at line 4)\n" + 
10726
		"	double foo(Collection<String> bar) {return 0; }\n" + 
10727
		"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
10728
		"Method foo(Collection<String>) has the same erasure foo(Collection<E>) as another method in type X\n" + 
10729
		"----------\n"
10730
	);
11204
	);
10731
/* javac 7
11205
/* javac 7
10732
X.java:4: foo(Collection) is already defined in X
11206
X.java:4: foo(Collection) is already defined in X

Return to bug 317719