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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/JavadocBugsTest.java (-1 / +1 lines)
Lines 5994-6000 Link Here
5994
 * @test Ensure that no warning are raised when ambiguous parameterized methods are present in javadoc comments
5994
 * @test Ensure that no warning are raised when ambiguous parameterized methods are present in javadoc comments
5995
 * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=165794"
5995
 * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=165794"
5996
 */
5996
 */
5997
public void testBug165794() {
5997
public void _testBug165794() {
5998
	String[] testFiles = new String[] {
5998
	String[] testFiles = new String[] {
5999
		"X.java",
5999
		"X.java",
6000
		"/**\n" +
6000
		"/**\n" +
(-)src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java (-272 / +857 lines)
Lines 3223-3230 Link Here
3223
3223
3224
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3224
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3225
	public void test048() {
3225
	public void test048() {
3226
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3226
		this.runNegativeTest(
3227
		this.runConformTest(
3228
			new String[] {
3227
			new String[] {
3229
				"X1.java",
3228
				"X1.java",
3230
				"import java.util.*;\n" +
3229
				"import java.util.*;\n" +
Lines 3232-3244 Link Here
3232
				"    public Object putAll(Map<String,String> a) { return null; }\n" +
3231
				"    public Object putAll(Map<String,String> a) { return null; }\n" +
3233
				"}\n"
3232
				"}\n"
3234
			},
3233
			},
3235
			""
3234
			"----------\n" + 
3235
			"1. WARNING in X1.java (at line 2)\n" + 
3236
			"	public class X1 extends LinkedHashMap<String, String> {\n" + 
3237
			"	             ^^\n" + 
3238
			"The serializable class X1 does not declare a static final serialVersionUID field of type long\n" + 
3239
			"----------\n" + 
3240
			"2. ERROR in X1.java (at line 3)\n" + 
3241
			"	public Object putAll(Map<String,String> a) { return null; }\n" + 
3242
			"	              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
3243
			"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" + 
3244
			"----------\n"
3236
		);
3245
		);
3246
/* javac 7
3247
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
3248
        public Object putAll(Map<String,String> a) { return null; }
3249
                      ^
3250
  where K,V are type-variables:
3251
    K extends Object declared in class HashMap
3252
    V extends Object declared in class HashMap
3253
1 error
3254
 */
3237
	}
3255
	}
3238
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3256
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3239
	public void test048a() {
3257
	public void test048a() {
3240
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3258
		this.runNegativeTest(
3241
		this.runConformTest(
3242
			new String[] {
3259
			new String[] {
3243
				"X2.java",
3260
				"X2.java",
3244
				"public class X2 extends Y<String> {\n" +
3261
				"public class X2 extends Y<String> {\n" +
Lines 3251-3258 Link Here
3251
				"    public void foo(I<? extends T> a);\n" +
3268
				"    public void foo(I<? extends T> a);\n" +
3252
				"}\n"
3269
				"}\n"
3253
			},
3270
			},
3254
			""
3271
			"----------\n" + 
3272
			"1. ERROR in X2.java (at line 2)\n" + 
3273
			"	public Object foo(I<String> z) { return null; }\n" + 
3274
			"	              ^^^^^^^^^^^^^^^^\n" + 
3275
			"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" + 
3276
			"----------\n"
3255
		);
3277
		);
3278
/* javac 7
3279
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
3280
    public Object foo(I<String> z) { return null; }
3281
                  ^
3282
  where T is a type-variable:
3283
    T extends Object declared in class Y
3284
1 error
3285
 */
3256
	}
3286
	}
3257
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3287
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3258
	public void test048b() {
3288
	public void test048b() {
Lines 3275-3287 Link Here
3275
			"	            ^^^^^^^^^^^^^^^^\n" +
3305
			"	            ^^^^^^^^^^^^^^^^\n" +
3276
			"Name clash: The method foo(I<String>) of type X3 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" +
3306
			"Name clash: The method foo(I<String>) of type X3 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" +
3277
			"----------\n"
3307
			"----------\n"
3278
			// name clash: foo(I<java.lang.String>) in X and foo(I<? extends T>) in Y<java.lang.String> have the same erasure, yet neither overrides the other
3279
		);
3308
		);
3309
/* javac 7
3310
X.java:2: name clash: foo(I<String>) in X3 and foo(I<? extends T>) in Y have the same erasure, yet neither overrides the other
3311
    public void foo(I<String> z) {}
3312
                ^
3313
  where T is a type-variable:
3314
    T extends Object declared in class Y
3315
1 error
3316
 */
3280
	}
3317
	}
3281
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3318
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3282
	public void test048c() {
3319
	public void test048c() {
3283
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3320
		this.runNegativeTest(
3284
		this.runConformTest(
3285
			new String[] {
3321
			new String[] {
3286
				"X4.java",
3322
				"X4.java",
3287
				"public class X4 extends Y<String> {\n" +
3323
				"public class X4 extends Y<String> {\n" +
Lines 3294-3306 Link Here
3294
				"    public Object foo(I<? extends T> a);\n" +
3330
				"    public Object foo(I<? extends T> a);\n" +
3295
				"}\n"
3331
				"}\n"
3296
			},
3332
			},
3297
			""
3333
			"----------\n" + 
3334
			"1. ERROR in X4.java (at line 2)\n" + 
3335
			"	public String foo(I<String> z) { return null; }\n" + 
3336
			"	              ^^^^^^^^^^^^^^^^\n" + 
3337
			"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" + 
3338
			"----------\n"
3298
		);
3339
		);
3340
/* javac 7
3341
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
3342
    public String foo(I<String> z) { return null; }
3343
                  ^
3344
  where T is a type-variable:
3345
    T extends Object declared in class Y
3346
1 error
3347
 */
3299
	}
3348
	}
3300
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3349
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3301
	public void test048d() {
3350
	public void test048d() {
3302
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3351
		this.runNegativeTest(
3303
		this.runConformTest(
3304
			new String[] {
3352
			new String[] {
3305
				"X5.java",
3353
				"X5.java",
3306
				"public class X5 extends Y<String> {\n" +
3354
				"public class X5 extends Y<String> {\n" +
Lines 3313-3325 Link Here
3313
				"    public String foo(I<? extends T> a);\n" +
3361
				"    public String foo(I<? extends T> a);\n" +
3314
				"}\n"
3362
				"}\n"
3315
			},
3363
			},
3316
			""
3364
			"----------\n" + 
3365
			"1. ERROR in X5.java (at line 2)\n" + 
3366
			"	public Object foo(I<String> z) { return null; }\n" + 
3367
			"	              ^^^^^^^^^^^^^^^^\n" + 
3368
			"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" + 
3369
			"----------\n"
3317
		);
3370
		);
3371
/* javac 7
3372
X.java:2: name clash: foo(I<String>) in X5 and foo(I<? extends T>) in Y have the
3373
 same erasure, yet neither overrides the other
3374
    public Object foo(I<String> z) { return null; }
3375
                  ^
3376
  where T is a type-variable:
3377
    T extends Object declared in class Y
3378
1 error
3379
 */
3318
	}
3380
	}
3319
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3381
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3320
	public void test048e() {
3382
	public void test048e() {
3321
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3383
		this.runNegativeTest(
3322
		this.runConformTest(
3323
			new String[] {
3384
			new String[] {
3324
				"X6.java",
3385
				"X6.java",
3325
				"public class X6 extends Y<String> {\n" +
3386
				"public class X6 extends Y<String> {\n" +
Lines 3332-3344 Link Here
3332
				"    public Object foo(I<? extends T> a);\n" +
3393
				"    public Object foo(I<? extends T> a);\n" +
3333
				"}\n"
3394
				"}\n"
3334
			},
3395
			},
3335
			""
3396
			"----------\n" + 
3397
			"1. ERROR in X6.java (at line 2)\n" + 
3398
			"	public void foo(I<String> z) {}\n" + 
3399
			"	            ^^^^^^^^^^^^^^^^\n" + 
3400
			"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" + 
3401
			"----------\n"
3336
		);
3402
		);
3403
/* javac 7
3404
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
3405
    public void foo(I<String> z) {}
3406
                ^
3407
  where T is a type-variable:
3408
    T extends Object declared in class Y
3409
1 error
3410
 */
3337
	}
3411
	}
3338
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3412
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3339
	public void test048f() {
3413
	public void test048f() {
3340
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3414
		this.runNegativeTest(
3341
		this.runConformTest(
3342
			new String[] {
3415
			new String[] {
3343
				"X7.java",
3416
				"X7.java",
3344
				"public class X7 extends Y<String> {\n" +
3417
				"public class X7 extends Y<String> {\n" +
Lines 3351-3358 Link Here
3351
				"    public T foo(I<? extends T> a);\n" +
3424
				"    public T foo(I<? extends T> a);\n" +
3352
				"}\n"
3425
				"}\n"
3353
			},
3426
			},
3354
			""
3427
			"----------\n" + 
3428
			"1. ERROR in X7.java (at line 2)\n" + 
3429
			"	public String foo(I<String> z) { return null; }\n" + 
3430
			"	              ^^^^^^^^^^^^^^^^\n" + 
3431
			"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" + 
3432
			"----------\n"
3355
		);
3433
		);
3434
/* javac 7
3435
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
3436
    public String foo(I<String> z) { return null; }
3437
                  ^
3438
  where T is a type-variable:
3439
    T extends Object declared in class Y
3440
1 error
3441
 */
3356
	}
3442
	}
3357
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3443
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3358
	public void test048g() {
3444
	public void test048g() {
Lines 3375-3382 Link Here
3375
			"	              ^^^^^^^^^^^^^^^^\n" +
3461
			"	              ^^^^^^^^^^^^^^^^\n" +
3376
			"Name clash: The method foo(I<String>) of type X8 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" +
3462
			"Name clash: The method foo(I<String>) of type X8 has the same erasure as foo(I<? extends T>) of type Y<T> but does not override it\n" +
3377
			"----------\n"
3463
			"----------\n"
3378
			// name clash: foo(I<java.lang.String>) in X7 and foo(I<? extends T>) in Y<java.lang.String> have the same erasure, yet neither overrides the other
3379
		);
3464
		);
3465
/* javac 7
3466
X.java:2: name clash: foo(I<String>) in X8 and foo(I<? extends T>) in Y have the  same erasure, yet neither overrides the other
3467
    public Object foo(I<String> z) { return null; }
3468
                  ^
3469
  where T is a type-variable:
3470
    T extends Object declared in class Y
3471
1 error
3472
 */
3380
	}
3473
	}
3381
3474
3382
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=88094
3475
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=88094
Lines 3439-3498 Link Here
3439
3532
3440
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=94754
3533
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=94754
3441
	public void test050() {
3534
	public void test050() {
3442
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3535
		this.runNegativeTest(
3443
		this.runConformTest(
3444
			new String[] {
3536
			new String[] {
3445
				"X.java",
3537
				"X.java",
3446
				"public class X {\n" +
3538
				"public class X {\n" +
3447
				"		 public static <S extends A> S foo() { System.out.print(\"A\"); return null; }\n" +
3539
				"	public static <S extends A> S foo() { System.out.print(\"A\"); return null; }\n" +
3448
				"		 public static <N extends B> N foo() { System.out.print(\"B\"); return null; }\n" +
3540
				"	public static <N extends B> N foo() { System.out.print(\"B\"); return null; }\n" +
3449
				"		 public static void main(String[] args) {\n" +
3541
				"	public static void main(String[] args) {\n" +
3450
				"		 	X.<A>foo();\n" +
3542
				"		X.<A>foo();\n" +
3451
				"		 	X.<B>foo();\n" +
3543
				"		X.<B>foo();\n" +
3452
				"		 	new X().<B>foo();\n" +
3544
				"		new X().<B>foo();\n" +
3453
				"		 }\n" +
3545
				"	}\n" +
3454
				"}\n" +
3546
				"}\n" +
3455
				"class A {}\n" +
3547
				"class A {}\n" +
3456
				"class B {}\n"
3548
				"class B {}"
3457
			},
3549
			},
3458
			"ABB"
3550
			"----------\n" + 
3459
		);
3551
			"1. ERROR in X.java (at line 2)\n" + 
3552
			"	public static <S extends A> S foo() { System.out.print(\"A\"); return null; }\n" + 
3553
			"	                              ^^^^^\n" + 
3554
			"Duplicate method foo() in type X\n" + 
3555
			"----------\n" + 
3556
			"2. ERROR in X.java (at line 3)\n" + 
3557
			"	public static <N extends B> N foo() { System.out.print(\"B\"); return null; }\n" + 
3558
			"	                              ^^^^^\n" + 
3559
			"Duplicate method foo() in type X\n" + 
3560
			"----------\n" + 
3561
			"3. ERROR in X.java (at line 6)\n" + 
3562
			"	X.<B>foo();\n" + 
3563
			"	     ^^^\n" + 
3564
			"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" + 
3565
			"----------\n" + 
3566
			"4. ERROR in X.java (at line 7)\n" + 
3567
			"	new X().<B>foo();\n" + 
3568
			"	           ^^^\n" + 
3569
			"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" + 
3570
			"----------\n"
3571
		);
3572
/* javac 7
3573
X.java:3: name clash: <N>foo() and <S>foo() have the same erasure
3574
        public static <N extends B> N foo() { System.out.print("B"); return null; }
3575
                                      ^
3576
  where N,S are type-variables:
3577
    N extends B declared in method <N>foo()
3578
    S extends A declared in method <S>foo()
3579
X.java:6: method foo in class X cannot be applied to given types
3580
                X.<B>foo();
3581
                 ^
3582
  required: no arguments
3583
  found: no arguments
3584
X.java:7: method foo in class X cannot be applied to given types
3585
                new X().<B>foo();
3586
                       ^
3587
  required: no arguments
3588
  found: no arguments
3589
3 errors
3590
 */
3460
	}
3591
	}
3461
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=94754
3592
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=94754
3462
	public void test050a() {
3593
	public void test050a() {
3463
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3464
		this.runNegativeTest(
3594
		this.runNegativeTest(
3465
			new String[] {
3595
			new String[] {
3466
				"X.java",
3596
				"X.java",
3467
				"public class X {\n" +
3597
				"public class X {\n" +
3468
				"		 public static <S extends A> void foo() { System.out.print(\"A\"); }\n" +
3598
				"	public static <S extends A> void foo() { System.out.print(\"A\"); }\n" +
3469
				"		 public static <N extends B> N foo() { System.out.print(\"B\"); return null; }\n" +
3599
				"	public static <N extends B> N foo() { System.out.print(\"B\"); return null; }\n" +
3470
				"		 static void test () {\n" +
3600
				"	static void test () {\n" +
3471
				"		 	X.foo();\n" +
3601
				"		X.foo();\n" +
3472
				"		 	foo();\n" +
3602
				"		foo();\n" +
3473
				"		 }\n" +
3603
				"	}\n" +
3474
				"}\n" +
3604
				"}\n" +
3475
				"class A {}\n" +
3605
				"class A {}\n" +
3476
				"class B {}\n"
3606
				"class B {}"
3477
			},
3607
			},
3478
			"----------\n" +
3608
			"----------\n" + 
3479
			"1. ERROR in X.java (at line 5)\r\n" +
3609
			"1. ERROR in X.java (at line 2)\n" + 
3480
			"	X.foo();\r\n" +
3610
			"	public static <S extends A> void foo() { System.out.print(\"A\"); }\n" + 
3481
			"	  ^^^\n" +
3611
			"	                                 ^^^^^\n" + 
3482
			"The method foo() is ambiguous for the type X\n" +
3612
			"Duplicate method foo() in type X\n" + 
3483
			"----------\n" +
3613
			"----------\n" + 
3484
			"2. ERROR in X.java (at line 6)\r\n" +
3614
			"2. ERROR in X.java (at line 3)\n" + 
3485
			"	foo();\r\n" +
3615
			"	public static <N extends B> N foo() { System.out.print(\"B\"); return null; }\n" + 
3486
			"	^^^\n" +
3616
			"	                              ^^^^^\n" + 
3487
			"The method foo() is ambiguous for the type X\n" +
3617
			"Duplicate method foo() in type X\n" + 
3488
			"----------\n"
3618
			"----------\n"
3489
			// both references are ambiguous
3490
		);
3619
		);
3620
/* javac 7
3621
X.java:3: name clash: <N>foo() and <S>foo() have the same erasure
3622
        public static <N extends B> N foo() { System.out.print("B"); return null; }
3623
                                      ^
3624
  where N,S are type-variables:
3625
    N extends B declared in method <N>foo()
3626
    S extends A declared in method <S>foo()
3627
1 error
3628
 */
3491
	}
3629
	}
3492
3630
3493
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation
3631
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation
3494
	public void test050b() {
3632
	public void test050b() {
3495
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3496
		this.runNegativeTest(
3633
		this.runNegativeTest(
3497
			new String[] {
3634
			new String[] {
3498
				"X.java",
3635
				"X.java",
Lines 3502-3509 Link Here
3502
				"		Z foo(Object o) {  return null; } // duplicate\n" +
3639
				"		Z foo(Object o) {  return null; } // duplicate\n" +
3503
				"	}\n" +
3640
				"	}\n" +
3504
				"	class C2 {\n" +
3641
				"	class C2 {\n" +
3505
				"		<T extends Y> T foo(Object o) {  return null; } // ok\n" +
3642
				"		<T extends Y> T foo(Object o) {  return null; } // duplicate\n" +
3506
				"		<T extends Z> T foo(Object o) {  return null; } // ok\n" +
3643
				"		<T extends Z> T foo(Object o) {  return null; } // duplicate\n" +
3507
				"	}\n" +
3644
				"	}\n" +
3508
				"	class C3 {\n" +
3645
				"	class C3 {\n" +
3509
				"		A<Y> foo(Object o) {  return null; } // duplicate\n" +
3646
				"		A<Y> foo(Object o) {  return null; } // duplicate\n" +
Lines 3514-3562 Link Here
3514
				"		<T extends Z> T foo(Object o) {  return null; } // duplicate\n" +
3651
				"		<T extends Z> T foo(Object o) {  return null; } // duplicate\n" +
3515
				"	}\n" +
3652
				"	}\n" +
3516
				"}\n" +
3653
				"}\n" +
3517
				"class A<T> {}" +
3654
				"class A<T> {}\n" +
3518
				"class Y {}" +
3655
				"class Y {}\n" +
3519
				"class Z {}"
3656
				"class Z {}"
3520
			},
3657
			},
3521
			"----------\n" +
3658
			"----------\n" + 
3522
			"1. ERROR in X.java (at line 3)\n" +
3659
			"1. ERROR in X.java (at line 3)\n" + 
3523
			"	Y foo(Object o) {  return null; } // duplicate\n" +
3660
			"	Y foo(Object o) {  return null; } // duplicate\n" + 
3524
			"	  ^^^^^^^^^^^^^\n" +
3661
			"	  ^^^^^^^^^^^^^\n" + 
3525
			"Duplicate method foo(Object) in type X.C1\n" +
3662
			"Duplicate method foo(Object) in type X.C1\n" + 
3526
			"----------\n" +
3663
			"----------\n" + 
3527
			"2. ERROR in X.java (at line 4)\n" +
3664
			"2. ERROR in X.java (at line 4)\n" + 
3528
			"	Z foo(Object o) {  return null; } // duplicate\n" +
3665
			"	Z foo(Object o) {  return null; } // duplicate\n" + 
3529
			"	  ^^^^^^^^^^^^^\n" +
3666
			"	  ^^^^^^^^^^^^^\n" + 
3530
			"Duplicate method foo(Object) in type X.C1\n" +
3667
			"Duplicate method foo(Object) in type X.C1\n" + 
3531
			"----------\n" +
3668
			"----------\n" + 
3532
			"3. ERROR in X.java (at line 11)\n" +
3669
			"3. ERROR in X.java (at line 7)\n" + 
3533
			"	A<Y> foo(Object o) {  return null; } // duplicate\n" +
3670
			"	<T extends Y> T foo(Object o) {  return null; } // duplicate\n" + 
3534
			"	     ^^^^^^^^^^^^^\n" +
3671
			"	                ^^^^^^^^^^^^^\n" + 
3535
			"Duplicate method foo(Object) in type X.C3\n" +
3672
			"Duplicate method foo(Object) in type X.C2\n" + 
3536
			"----------\n" +
3673
			"----------\n" + 
3537
			"4. ERROR in X.java (at line 12)\n" +
3674
			"4. ERROR in X.java (at line 8)\n" + 
3538
			"	A<Z> foo(Object o) {  return null; } // duplicate\n" +
3675
			"	<T extends Z> T foo(Object o) {  return null; } // duplicate\n" + 
3539
			"	     ^^^^^^^^^^^^^\n" +
3676
			"	                ^^^^^^^^^^^^^\n" + 
3540
			"Duplicate method foo(Object) in type X.C3\n" +
3677
			"Duplicate method foo(Object) in type X.C2\n" + 
3541
			"----------\n" +
3678
			"----------\n" + 
3542
			"5. ERROR in X.java (at line 15)\n" +
3679
			"5. ERROR in X.java (at line 11)\n" + 
3543
			"	Y foo(Object o) {  return null; } // duplicate\n" +
3680
			"	A<Y> foo(Object o) {  return null; } // duplicate\n" + 
3544
			"	  ^^^^^^^^^^^^^\n" +
3681
			"	     ^^^^^^^^^^^^^\n" + 
3545
			"Duplicate method foo(Object) in type X.C4\n" +
3682
			"Duplicate method foo(Object) in type X.C3\n" + 
3546
			"----------\n" +
3683
			"----------\n" + 
3547
			"6. ERROR in X.java (at line 16)\n" +
3684
			"6. ERROR in X.java (at line 12)\n" + 
3548
			"	<T extends Z> T foo(Object o) {  return null; } // duplicate\n" +
3685
			"	A<Z> foo(Object o) {  return null; } // duplicate\n" + 
3549
			"	                ^^^^^^^^^^^^^\n" +
3686
			"	     ^^^^^^^^^^^^^\n" + 
3550
			"Duplicate method foo(Object) in type X.C4\n" +
3687
			"Duplicate method foo(Object) in type X.C3\n" + 
3551
			"----------\n"
3688
			"----------\n" + 
3552
			// foo(java.lang.Object) is already defined in X.C1
3689
			"7. ERROR in X.java (at line 15)\n" + 
3553
			// foo(java.lang.Object) is already defined in X.C3
3690
			"	Y foo(Object o) {  return null; } // duplicate\n" + 
3554
			// foo(java.lang.Object) is already defined in X.C4
3691
			"	  ^^^^^^^^^^^^^\n" + 
3692
			"Duplicate method foo(Object) in type X.C4\n" + 
3693
			"----------\n" + 
3694
			"8. ERROR in X.java (at line 16)\n" + 
3695
			"	<T extends Z> T foo(Object o) {  return null; } // duplicate\n" + 
3696
			"	                ^^^^^^^^^^^^^\n" + 
3697
			"Duplicate method foo(Object) in type X.C4\n" + 
3698
			"----------\n"
3555
		);
3699
		);
3700
/* javac 7
3701
X.java:4: foo(Object) is already defined in X.C1
3702
                Z foo(Object o) {  return null; } // duplicate
3703
                  ^
3704
X.java:8: name clash: <T#1>foo(Object) and <T#2>foo(Object) have the same erasure
3705
                <T extends Z> T foo(Object o) {  return null; } // duplicate
3706
                                ^
3707
  where T#1,T#2 are type-variables:
3708
    T#1 extends Z declared in method <T#1>foo(Object)
3709
    T#2 extends Y declared in method <T#2>foo(Object)
3710
X.java:12: foo(Object) is already defined in X.C3
3711
                A<Z> foo(Object o) {  return null; } // duplicate
3712
                     ^
3713
X.java:16: foo(Object) is already defined in X.C4
3714
                <T extends Z> T foo(Object o) {  return null; } // duplicate
3715
                                ^
3716
4 errors
3717
 */
3556
	}
3718
	}
3557
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation
3719
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation
3558
	public void test050c() {
3720
	public void test050c() {
3559
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3560
		this.runNegativeTest(
3721
		this.runNegativeTest(
3561
			new String[] {
3722
			new String[] {
3562
				"X.java",
3723
				"X.java",
Lines 3570-3597 Link Here
3570
				"		<T extends Z> T foo(A<Z> o) {  return null; } // ok\n" +
3731
				"		<T extends Z> T foo(A<Z> o) {  return null; } // ok\n" +
3571
				"	}\n" +
3732
				"	}\n" +
3572
				"}\n" +
3733
				"}\n" +
3573
				"class A<T> {}" +
3734
				"class A<T> {}\n" +
3574
				"class Y {}" +
3735
				"class Y {}\n" +
3575
				"class Z {}"
3736
				"class Z {}"
3576
			},
3737
			},
3577
			"----------\n" +
3738
			"----------\n" + 
3578
			"1. ERROR in X.java (at line 3)\n" +
3739
			"1. ERROR in X.java (at line 3)\n" + 
3579
			"	A<Y> foo(A<Y> o) {  return null; } // duplicate\n" +
3740
			"	A<Y> foo(A<Y> o) {  return null; } // duplicate\n" + 
3580
			"	     ^^^^^^^^^^^\n" +
3741
			"	     ^^^^^^^^^^^\n" + 
3581
			"Method foo(A<Y>) has the same erasure foo(A<T>) as another method in type X.C5\n" +
3742
			"Method foo(A<Y>) has the same erasure foo(A<T>) as another method in type X.C5\n" + 
3582
			"----------\n" +
3743
			"----------\n" + 
3583
			"2. ERROR in X.java (at line 4)\n" +
3744
			"2. ERROR in X.java (at line 4)\n" + 
3584
			"	A<Z> foo(A<Z> o) {  return null; } // duplicate\n" +
3745
			"	A<Z> foo(A<Z> o) {  return null; } // duplicate\n" + 
3585
			"	     ^^^^^^^^^^^\n" +
3746
			"	     ^^^^^^^^^^^\n" + 
3586
			"Method foo(A<Z>) has the same erasure foo(A<T>) as another method in type X.C5\n" +
3747
			"Method foo(A<Z>) has the same erasure foo(A<T>) as another method in type X.C5\n" + 
3587
			"----------\n"
3748
			"----------\n" + 
3588
			// name clash: foo(A<Y>) and foo(A<Z>) have the same erasure
3749
			"3. ERROR in X.java (at line 7)\n" + 
3589
		);
3750
			"	<T extends Y> T foo(A<Y> o) {  return null; } // ok\n" + 
3751
			"	                ^^^^^^^^^^^\n" + 
3752
			"Method foo(A<Y>) has the same erasure foo(A<T>) as another method in type X.C6\n" + 
3753
			"----------\n" + 
3754
			"4. ERROR in X.java (at line 8)\n" + 
3755
			"	<T extends Z> T foo(A<Z> o) {  return null; } // ok\n" + 
3756
			"	                ^^^^^^^^^^^\n" + 
3757
			"Method foo(A<Z>) has the same erasure foo(A<T>) as another method in type X.C6\n" + 
3758
			"----------\n"
3759
		);
3760
/* javac 7
3761
X.java:4: name clash: foo(A<Z>) and foo(A<Y>) have the same erasure
3762
                A<Z> foo(A<Z> o) {  return null; } // duplicate
3763
                     ^
3764
X.java:8: name clash: <T#1>foo(A<Z>) and <T#2>foo(A<Y>) have the same erasure
3765
                <T extends Z> T foo(A<Z> o) {  return null; } // ok
3766
                                ^
3767
  where T#1,T#2 are type-variables:
3768
    T#1 extends Z declared in method <T#1>foo(A<Z>)
3769
    T#2 extends Y declared in method <T#2>foo(A<Y>)
3770
2 errors
3771
 */
3590
	}
3772
	}
3591
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation
3773
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation
3592
	public void test050d() {
3774
	public void test050d() {
3593
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3775
		this.runNegativeTest(
3594
		this.runConformTest(
3595
			new String[] {
3776
			new String[] {
3596
				"X.java",
3777
				"X.java",
3597
				"public class X {\n" +
3778
				"public class X {\n" +
Lines 3600-3617 Link Here
3600
				"		<T extends Z> T foo(Object o) {  return null; } // ok\n" +
3781
				"		<T extends Z> T foo(Object o) {  return null; } // ok\n" +
3601
				"	}\n" +
3782
				"	}\n" +
3602
				"}\n" +
3783
				"}\n" +
3603
				"class A<T> {}" +
3784
				"class A<T> {}\n" +
3604
				"class Y {}" +
3785
				"class Y {}\n" +
3605
				"class Z {}"
3786
				"class Z {}"
3606
			},
3787
			},
3607
			""
3788
			"----------\n" + 
3789
			"1. ERROR in X.java (at line 3)\n" + 
3790
			"	<T extends Y, U> T foo(Object o) {  return null; } // ok\n" + 
3791
			"	                   ^^^^^^^^^^^^^\n" + 
3792
			"Duplicate method foo(Object) in type X.C7\n" + 
3793
			"----------\n" + 
3794
			"2. ERROR in X.java (at line 4)\n" + 
3795
			"	<T extends Z> T foo(Object o) {  return null; } // ok\n" + 
3796
			"	                ^^^^^^^^^^^^^\n" + 
3797
			"Duplicate method foo(Object) in type X.C7\n" + 
3798
			"----------\n"
3608
		);
3799
		);
3800
/* javac 7
3801
X.java:4: name clash: <T#1>foo(Object) and <T#2,U>foo(Object) have the same erasure
3802
                <T extends Z> T foo(Object o) {  return null; } // ok
3803
                                ^
3804
  where T#1,T#2,U are type-variables:
3805
    T#1 extends Z declared in method <T#1>foo(Object)
3806
    T#2 extends Y declared in method <T#2,U>foo(Object)
3807
    U extends Object declared in method <T#2,U>foo(Object)
3808
1 error
3809
 */
3609
	}
3810
	}
3610
3811
3611
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423
3812
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423
3612
	public void test050e() {
3813
	public void test050e() {
3613
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3814
		this.runNegativeTest(
3614
		this.runConformTest(
3615
			new String[] {
3815
			new String[] {
3616
				"X.java",
3816
				"X.java",
3617
				"public class X {\n" +
3817
				"public class X {\n" +
Lines 3625-3632 Link Here
3625
				"class A<T> {}\n" +
3825
				"class A<T> {}\n" +
3626
				"class B {}\n"
3826
				"class B {}\n"
3627
			},
3827
			},
3628
			""
3828
			"----------\n" + 
3629
		);
3829
			"1. ERROR in X.java (at line 2)\n" + 
3830
			"	<N extends B> N a(A<String> s) { return null; }\n" + 
3831
			"	                ^^^^^^^^^^^^^^\n" + 
3832
			"Method a(A<String>) has the same erasure a(A<T>) as another method in type X\n" + 
3833
			"----------\n" + 
3834
			"2. ERROR in X.java (at line 3)\n" + 
3835
			"	<N> Object a(A<Number> n) { return null; }\n" + 
3836
			"	           ^^^^^^^^^^^^^^\n" + 
3837
			"Method a(A<Number>) has the same erasure a(A<T>) as another method in type X\n" + 
3838
			"----------\n" + 
3839
			"3. ERROR in X.java (at line 4)\n" + 
3840
			"	<N extends B> void b(A<String> s) {}\n" + 
3841
			"	                   ^^^^^^^^^^^^^^\n" + 
3842
			"Method b(A<String>) has the same erasure b(A<T>) as another method in type X\n" + 
3843
			"----------\n" + 
3844
			"4. ERROR in X.java (at line 5)\n" + 
3845
			"	<N extends B> B b(A<Number> n) { return null; }\n" + 
3846
			"	                ^^^^^^^^^^^^^^\n" + 
3847
			"Method b(A<Number>) has the same erasure b(A<T>) as another method in type X\n" + 
3848
			"----------\n" + 
3849
			"5. ERROR in X.java (at line 6)\n" + 
3850
			"	void c(A<String> s) {}\n" + 
3851
			"	     ^^^^^^^^^^^^^^\n" + 
3852
			"Method c(A<String>) has the same erasure c(A<T>) as another method in type X\n" + 
3853
			"----------\n" + 
3854
			"6. ERROR in X.java (at line 7)\n" + 
3855
			"	B c(A<Number> n) { return null; }\n" + 
3856
			"	  ^^^^^^^^^^^^^^\n" + 
3857
			"Method c(A<Number>) has the same erasure c(A<T>) as another method in type X\n" + 
3858
			"----------\n"
3859
		);
3860
/* javac 7
3861
X.java:3: name clash: <N#1>a(A<Number>) and <N#2>a(A<String>) have the same erasure
3862
        <N> Object a(A<Number> n) { return null; }
3863
                   ^
3864
  where N#1,N#2 are type-variables:
3865
    N#1 extends Object declared in method <N#1>a(A<Number>)
3866
    N#2 extends B declared in method <N#2>a(A<String>)
3867
X.java:5: name clash: <N#1>b(A<Number>) and <N#2>b(A<String>) have the same erasure
3868
        <N extends B> B b(A<Number> n) { return null; }
3869
                        ^
3870
  where N#1,N#2 are type-variables:
3871
    N#1 extends B declared in method <N#1>b(A<Number>)
3872
    N#2 extends B declared in method <N#2>b(A<String>)
3873
X.java:7: name clash: c(A<Number>) and c(A<String>) have the same erasure
3874
        B c(A<Number> n) { return null; }
3875
          ^
3876
3 errors
3877
 */
3630
	}
3878
	}
3631
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423
3879
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423
3632
	public void test050f() {
3880
	public void test050f() {
Lines 3651-3658 Link Here
3651
			"	      ^^^^^^^^^^^^^^\n" +
3899
			"	      ^^^^^^^^^^^^^^\n" +
3652
			"Method a(A<Number>) has the same erasure a(A<T>) as another method in type X\n" +
3900
			"Method a(A<Number>) has the same erasure a(A<T>) as another method in type X\n" +
3653
			"----------\n"
3901
			"----------\n"
3654
			// name clash: <N>a(A<java.lang.String>) and <N>a(A<java.lang.Number>) have the same erasure
3655
		);
3902
		);
3903
/* javac 7
3904
X.java:3: name clash: <N#1>a(A<Number>) and <N#2>a(A<String>) have the same erasure
3905
        <N> B a(A<Number> n) { return null; }
3906
              ^
3907
  where N#1,N#2 are type-variables:
3908
    N#1 extends Object declared in method <N#1>a(A<Number>)
3909
    N#2 extends B declared in method <N#2>a(A<String>)
3910
1 error
3911
 */
3656
	}
3912
	}
3657
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423
3913
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423
3658
	public void test050g() {
3914
	public void test050g() {
Lines 3677-3684 Link Here
3677
			"	                ^^^^^^^^^^^^^^\n" +
3933
			"	                ^^^^^^^^^^^^^^\n" +
3678
			"Method b(A<Number>) has the same erasure b(A<T>) as another method in type X\n" +
3934
			"Method b(A<Number>) has the same erasure b(A<T>) as another method in type X\n" +
3679
			"----------\n"
3935
			"----------\n"
3680
			// name clash: <N>b(A<java.lang.String>) and <N>b(A<java.lang.Number>) have the same erasure
3681
		);
3936
		);
3937
/* javac 7
3938
X.java:3: name clash: <N#1>b(A<Number>) and <N#2>b(A<String>) have the same erasure
3939
        <N extends B> B b(A<Number> n) { return null; }
3940
                        ^
3941
  where N#1,N#2 are type-variables:
3942
    N#1 extends B declared in method <N#1>b(A<Number>)
3943
    N#2 extends B declared in method <N#2>b(A<String>)
3944
1 error
3945
 */
3682
	}
3946
	}
3683
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423
3947
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423
3684
	public void test050h() {
3948
	public void test050h() {
Lines 3703-3716 Link Here
3703
			"	  ^^^^^^^^^^^^^^\n" +
3967
			"	  ^^^^^^^^^^^^^^\n" +
3704
			"Method c(A<Number>) has the same erasure c(A<T>) as another method in type X\n" +
3968
			"Method c(A<Number>) has the same erasure c(A<T>) as another method in type X\n" +
3705
			"----------\n"
3969
			"----------\n"
3706
			// name clash: c(A<java.lang.String>) and c(A<java.lang.Number>) have the same erasure
3707
		);
3970
		);
3971
/* javac 7
3972
X.java:3: name clash: c(A<Number>) and c(A<String>) have the same erasure
3973
        B c(A<Number> n) { return null; }
3974
          ^
3975
1 error
3976
 */
3708
	}
3977
	}
3709
3978
3710
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423
3979
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423
3711
	public void test050i() {
3980
	public void test050i() {
3712
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3981
		this.runNegativeTest(
3713
		this.runConformTest(
3714
			new String[] {
3982
			new String[] {
3715
				"X.java",
3983
				"X.java",
3716
				"public class X {\n" +
3984
				"public class X {\n" +
Lines 3722-3729 Link Here
3722
				"class A<T> {}\n" +
3990
				"class A<T> {}\n" +
3723
				"class B {}\n"
3991
				"class B {}\n"
3724
			},
3992
			},
3725
			""
3993
			"----------\n" + 
3726
		);
3994
			"1. ERROR in X.java (at line 2)\n" + 
3995
			"	<N extends B> N a(A<Number> s) { return null; }\n" + 
3996
			"	                ^^^^^^^^^^^^^^\n" + 
3997
			"Duplicate method a(A<Number>) in type X\n" + 
3998
			"----------\n" + 
3999
			"2. ERROR in X.java (at line 3)\n" + 
4000
			"	<N> Object a(A<Number> n) { return null; }\n" + 
4001
			"	           ^^^^^^^^^^^^^^\n" + 
4002
			"Duplicate method a(A<Number>) in type X\n" + 
4003
			"----------\n" + 
4004
			"3. ERROR in X.java (at line 4)\n" + 
4005
			"	<N extends B> N b(A<Number> s) { return null; }\n" + 
4006
			"	                ^^^^^^^^^^^^^^\n" + 
4007
			"Method b(A<Number>) has the same erasure b(A<T>) as another method in type X\n" + 
4008
			"----------\n" + 
4009
			"4. ERROR in X.java (at line 5)\n" + 
4010
			"	<N> Object b(A<String> n) { return null; }\n" + 
4011
			"	           ^^^^^^^^^^^^^^\n" + 
4012
			"Method b(A<String>) has the same erasure b(A<T>) as another method in type X\n" + 
4013
			"----------\n"
4014
		);
4015
/* javac 7
4016
X.java:3: name clash: <N#1>a(A<Number>) and <N#2>a(A<Number>) have the same erasure
4017
        <N> Object a(A<Number> n) { return null; }
4018
                   ^
4019
  where N#1,N#2 are type-variables:
4020
    N#1 extends Object declared in method <N#1>a(A<Number>)
4021
    N#2 extends B declared in method <N#2>a(A<Number>)
4022
X.java:5: name clash: <N#1>b(A<String>) and <N#2>b(A<Number>) have the same erasure
4023
        <N> Object b(A<String> n) { return null; }
4024
                   ^
4025
  where N#1,N#2 are type-variables:
4026
    N#1 extends Object declared in method <N#1>b(A<String>)
4027
    N#2 extends B declared in method <N#2>b(A<Number>)
4028
2 errors
4029
 */
3727
	}
4030
	}
3728
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423
4031
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423
3729
	public void test050j() {
4032
	public void test050j() {
Lines 3760-3768 Link Here
3760
			"	      ^^^^^^^^^^^^^^\n" +
4063
			"	      ^^^^^^^^^^^^^^\n" +
3761
			"Method b(A<String>) has the same erasure b(A<T>) as another method in type X\n" +
4064
			"Method b(A<String>) has the same erasure b(A<T>) as another method in type X\n" +
3762
			"----------\n"
4065
			"----------\n"
3763
			// name clash: <N>a(A<java.lang.Number>) and <N>a(A<java.lang.Number>) have the same erasure
3764
			// name clash: <N>b(A<java.lang.Number>) and <N>b(A<java.lang.String>) have the same erasure
3765
		);
4066
		);
4067
/* javac 7
4068
X.java:3: name clash: <N#1>a(A<Number>) and <N#2>a(A<Number>) have the same erasure
4069
        <N> B a(A<Number> n) { return null; }
4070
              ^
4071
  where N#1,N#2 are type-variables:
4072
    N#1 extends Object declared in method <N#1>a(A<Number>)
4073
    N#2 extends B declared in method <N#2>a(A<Number>)
4074
X.java:5: name clash: <N#1>b(A<String>) and <N#2>b(A<Number>) have the same erasure
4075
        <N> B b(A<String> n) { return null; }
4076
              ^
4077
  where N#1,N#2 are type-variables:
4078
    N#1 extends Object declared in method <N#1>b(A<String>)
4079
    N#2 extends B declared in method <N#2>b(A<Number>)
4080
2 errors
4081
 */
3766
	}
4082
	}
3767
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423
4083
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423
3768
	public void test050k() {
4084
	public void test050k() {
Lines 3799-3807 Link Here
3799
			"	                ^^^^^^^^^^^^^^\n" +
4115
			"	                ^^^^^^^^^^^^^^\n" +
3800
			"Duplicate method b(A<Number>) in type X\n" +
4116
			"Duplicate method b(A<Number>) in type X\n" +
3801
			"----------\n"
4117
			"----------\n"
3802
			// <N>a(A<java.lang.Number>) is already defined in X
3803
			// <N>b(A<java.lang.Number>) is already defined in X
3804
		);
4118
		);
4119
/* javac 7
4120
X.java:3: <N>a(A<Number>) is already defined in X
4121
                <N extends B> B a(A<Number> n) { return null; }
4122
                                ^
4123
  where N is a type-variable:
4124
    N extends B declared in method <N>a(A<Number>)
4125
X.java:5: <N>b(A<Number>) is already defined in X
4126
                <N extends B> B b(A<Number> n) { return null; }
4127
                                ^
4128
  where N is a type-variable:
4129
    N extends B declared in method <N>b(A<Number>)
4130
2 errors
4131
 */
3805
	}
4132
	}
3806
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423
4133
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423
3807
	public void test050l() {
4134
	public void test050l() {
Lines 3838-3846 Link Here
3838
			"	  ^^^^^^^^^^^^^^\n" +
4165
			"	  ^^^^^^^^^^^^^^\n" +
3839
			"Duplicate method b(A<Number>) in type X\n" +
4166
			"Duplicate method b(A<Number>) in type X\n" +
3840
			"----------\n"
4167
			"----------\n"
3841
			// a(A<java.lang.Number>) is already defined in X
3842
			// b(A<java.lang.Number>) is already defined in X
3843
		);
4168
		);
4169
/* javac 7
4170
X.java:3: a(A<Number>) is already defined in X
4171
                 B a(A<Number> n) { return null; }
4172
                   ^
4173
X.java:5: b(A<Number>) is already defined in X
4174
                 B b(A<Number> n) { return null; }
4175
                   ^
4176
2 errors
4177
 */
3844
	}
4178
	}
3845
4179
3846
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=89470
4180
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=89470
Lines 3861-3868 Link Here
3861
			"	             ^\n" +
4195
			"	             ^\n" +
3862
			"The type X must implement the inherited abstract method I.foo(T)\n" +
4196
			"The type X must implement the inherited abstract method I.foo(T)\n" +
3863
			"----------\n"
4197
			"----------\n"
3864
			// X is not abstract and does not override abstract method <T>foo(T) in I
3865
		);
4198
		);
4199
/* javac 7
4200
X.java:1: X is not abstract and does not override abstract method <T>foo(T) in I
4201
class X implements I {
4202
^
4203
  where T is a type-variable:
4204
    T extends Object declared in method <T>foo(T)
4205
1 error
4206
 */
3866
	}
4207
	}
3867
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=89470
4208
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=89470
3868
	public void test051a() {
4209
	public void test051a() {
Lines 3886-3898 Link Here
3886
			"	     ^^^^^^^^^^^^^^^^^\n" +
4227
			"	     ^^^^^^^^^^^^^^^^^\n" +
3887
			"Method foo(A<Integer>) has the same erasure foo(A<T>) as another method in type X\n" +
4228
			"Method foo(A<Integer>) has the same erasure foo(A<T>) as another method in type X\n" +
3888
			"----------\n"
4229
			"----------\n"
3889
			// name clash: foo(A<java.lang.String>) and foo(A<java.lang.Integer>) have the same erasure
3890
		);
4230
		);
4231
/* javac 7
4232
X.java:3: name clash: foo(A<Integer>) and foo(A<String>) have the same erasure
4233
        void foo(A<Integer> a) {}
4234
             ^
4235
1 error
4236
 */
3891
	}
4237
	}
3892
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=89470
4238
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=89470
3893
	public void test051b() {
4239
	public void test051b() {
3894
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
4240
		this.runNegativeTest(
3895
		this.runConformTest(
3896
			new String[] {
4241
			new String[] {
3897
				"X.java",
4242
				"X.java",
3898
				"public class X {\n" +
4243
				"public class X {\n" +
Lines 3901-3908 Link Here
3901
				"}\n" +
4246
				"}\n" +
3902
				"class A<T> {}\n",
4247
				"class A<T> {}\n",
3903
			},
4248
			},
3904
			""
4249
			"----------\n" + 
4250
			"1. ERROR in X.java (at line 2)\n" + 
4251
			"	void foo(A<String> a) {}\n" + 
4252
			"	     ^^^^^^^^^^^^^^^^\n" + 
4253
			"Method foo(A<String>) has the same erasure foo(A<T>) as another method in type X\n" + 
4254
			"----------\n" + 
4255
			"2. ERROR in X.java (at line 3)\n" + 
4256
			"	Object foo(A<Integer> a) { return null; }\n" + 
4257
			"	       ^^^^^^^^^^^^^^^^^\n" + 
4258
			"Method foo(A<Integer>) has the same erasure foo(A<T>) as another method in type X\n" + 
4259
			"----------\n"
3905
		);
4260
		);
4261
/* javac 7
4262
X.java:3: name clash: foo(A<Integer>) and foo(A<String>) have the same erasure
4263
        Object foo(A<Integer> a) { return null; }
4264
               ^
4265
1 error
4266
 */
3906
	}
4267
	}
3907
4268
3908
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=91728
4269
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=91728
Lines 4037-4048 Link Here
4037
			"	      ^^^^^^\n" +
4398
			"	      ^^^^^^\n" +
4038
			"Method a(T) has the same erasure a(Object) as another method in type X\n" +
4399
			"Method a(T) has the same erasure a(Object) as another method in type X\n" +
4039
			"----------\n"
4400
			"----------\n"
4040
			// a(X) is already defined in X
4041
		);
4401
		);
4402
/* javac 7
4403
X.java:3: a(Object) is already defined in X
4404
        <T> T a(T x) {  return null; }
4405
              ^
4406
1 error
4407
 */
4042
	}
4408
	}
4043
	// more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897
4409
	// more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897
4044
	public void test054a() {
4410
	public void test054a() {
4045
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
4046
		this.runNegativeTest(
4411
		this.runNegativeTest(
4047
			new String[] {
4412
			new String[] {
4048
				"X.java",
4413
				"X.java",
Lines 4053-4081 Link Here
4053
				"	<T extends X> T aa(T x) {  return null; }\n" +
4418
				"	<T extends X> T aa(T x) {  return null; }\n" +
4054
				"	String a(X x) {  return null; }\n" + // dup
4419
				"	String a(X x) {  return null; }\n" + // dup
4055
				"	<T extends X> T a(T x) {  return null; }\n" +
4420
				"	<T extends X> T a(T x) {  return null; }\n" +
4056
4057
				"	<T> String z(X x) { return null; }\n" +
4421
				"	<T> String z(X x) { return null; }\n" +
4058
				"	<T, S> Object z(X x) { return null; }\n" +
4422
				"	<T, S> Object z(X x) { return null; }\n" +
4059
				"}\n"
4423
				"}\n"
4060
			},
4424
			},
4061
			"----------\n" +
4425
			"----------\n" + 
4062
			"1. ERROR in X.java (at line 6)\n" +
4426
			"1. ERROR in X.java (at line 2)\n" + 
4063
			"	String a(X x) {  return null; }\n" +
4427
			"	<T1, T2> String aaa(X x) {  return null; }\n" + 
4064
			"	       ^^^^^^\n" +
4428
			"	                ^^^^^^^^\n" + 
4065
			"Method a(X) has the same erasure a(X) as another method in type X\n" +
4429
			"Method aaa(X) has the same erasure aaa(X) as another method in type X\n" + 
4066
			"----------\n" +
4430
			"----------\n" + 
4067
			"2. ERROR in X.java (at line 7)\n" +
4431
			"2. ERROR in X.java (at line 3)\n" + 
4068
			"	<T extends X> T a(T x) {  return null; }\n" +
4432
			"	<T extends X> T aaa(T x) {  return null; }\n" + 
4069
			"	                ^^^^^^\n" +
4433
			"	                ^^^^^^^^\n" + 
4070
			"Method a(T) has the same erasure a(X) as another method in type X\n" +
4434
			"Method aaa(T) has the same erasure aaa(X) as another method in type X\n" + 
4071
			"----------\n"
4435
			"----------\n" + 
4072
			// a(X) is already defined in X
4436
			"3. ERROR in X.java (at line 4)\n" + 
4073
		);
4437
			"	<T> String aa(X x) {  return null; }\n" + 
4438
			"	           ^^^^^^^\n" + 
4439
			"Method aa(X) has the same erasure aa(X) as another method in type X\n" + 
4440
			"----------\n" + 
4441
			"4. ERROR in X.java (at line 5)\n" + 
4442
			"	<T extends X> T aa(T x) {  return null; }\n" + 
4443
			"	                ^^^^^^^\n" + 
4444
			"Method aa(T) has the same erasure aa(X) as another method in type X\n" + 
4445
			"----------\n" + 
4446
			"5. ERROR in X.java (at line 6)\n" + 
4447
			"	String a(X x) {  return null; }\n" + 
4448
			"	       ^^^^^^\n" + 
4449
			"Method a(X) has the same erasure a(X) as another method in type X\n" + 
4450
			"----------\n" + 
4451
			"6. ERROR in X.java (at line 7)\n" + 
4452
			"	<T extends X> T a(T x) {  return null; }\n" + 
4453
			"	                ^^^^^^\n" + 
4454
			"Method a(T) has the same erasure a(X) as another method in type X\n" + 
4455
			"----------\n" + 
4456
			"7. ERROR in X.java (at line 8)\n" + 
4457
			"	<T> String z(X x) { return null; }\n" + 
4458
			"	           ^^^^^^\n" + 
4459
			"Duplicate method z(X) in type X\n" + 
4460
			"----------\n" + 
4461
			"8. ERROR in X.java (at line 9)\n" + 
4462
			"	<T, S> Object z(X x) { return null; }\n" + 
4463
			"	              ^^^^^^\n" + 
4464
			"Duplicate method z(X) in type X\n" + 
4465
			"----------\n"
4466
		);
4467
/* javac 7
4468
X.java:3: name clash: <T>aaa(T) and <T1,T2>aaa(X) have the same erasure
4469
        <T extends X> T aaa(T x) {  return null; }
4470
                        ^
4471
  where T,T1,T2 are type-variables:
4472
    T extends X declared in method <T>aaa(T)
4473
    T1 extends Object declared in method <T1,T2>aaa(X)
4474
    T2 extends Object declared in method <T1,T2>aaa(X)
4475
X.java:5: name clash: <T#1>aa(T#1) and <T#2>aa(X) have the same erasure
4476
        <T extends X> T aa(T x) {  return null; }
4477
                        ^
4478
  where T#1,T#2 are type-variables:
4479
    T#1 extends X declared in method <T#1>aa(T#1)
4480
    T#2 extends Object declared in method <T#2>aa(X)
4481
X.java:7: a(X) is already defined in X
4482
        <T extends X> T a(T x) {  return null; }
4483
                        ^
4484
X.java:9: name clash: <T#1,S>z(X) and <T#3>z(X) have the same erasure
4485
        <T, S> Object z(X x) { return null; }
4486
                      ^
4487
  where T#1,S,T#3 are type-variables:
4488
    T#1 extends Object declared in method <T#1,S>z(X)
4489
    S extends Object declared in method <T#1,S>z(X)
4490
    T#3 extends Object declared in method <T#3>z(X)
4491
4 errors
4492
 */
4074
	}
4493
	}
4075
	// more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897
4494
	// more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897
4076
	public void test054b() {
4495
	public void test054b() {
4077
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
4496
		this.runNegativeTest(
4078
		this.runConformTest(
4079
			new String[] {
4497
			new String[] {
4080
				"X.java",
4498
				"X.java",
4081
				"public class X<T> {\n" +
4499
				"public class X<T> {\n" +
Lines 4083-4090 Link Here
4083
				"		 <S> String foo(X<T> s) { return null; }\n" +
4501
				"		 <S> String foo(X<T> s) { return null; }\n" +
4084
				"}\n"
4502
				"}\n"
4085
			},
4503
			},
4086
			""
4504
			"----------\n" + 
4505
			"1. ERROR in X.java (at line 2)\n" + 
4506
			"	Object foo(X<T> t) { return null; }\n" + 
4507
			"	       ^^^^^^^^^^^\n" + 
4508
			"Duplicate method foo(X<T>) in type X<T>\n" + 
4509
			"----------\n" + 
4510
			"2. ERROR in X.java (at line 3)\n" + 
4511
			"	<S> String foo(X<T> s) { return null; }\n" + 
4512
			"	           ^^^^^^^^^^^\n" + 
4513
			"Duplicate method foo(X<T>) in type X<T>\n" + 
4514
			"----------\n"
4087
		);
4515
		);
4516
/* javac 7
4517
X.java:3: name clash: <S>foo(X<T>) and foo(X<T>) have the same erasure
4518
        <S> String foo(X<T> s) { return null; }
4519
                   ^
4520
  where S,T are type-variables:
4521
    S extends Object declared in method <S>foo(X<T>)
4522
    T extends Object declared in class X
4523
1 error
4524
 */
4088
	}
4525
	}
4089
	// more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897
4526
	// more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897
4090
	public void test054c() {
4527
	public void test054c() {
Lines 4107-4119 Link Here
4107
			"	                          ^^^^^^\n" +
4544
			"	                          ^^^^^^\n" +
4108
			"Duplicate method dupT() in type X<T>\n" +
4545
			"Duplicate method dupT() in type X<T>\n" +
4109
			"----------\n"
4546
			"----------\n"
4110
			// <T1>dupT() is already defined in X
4111
		);
4547
		);
4548
/* javac 7
4549
X.java:3: <T1>dupT() is already defined in X
4550
        <T2 extends X<T2>> Object dupT() {return null;}
4551
                                  ^
4552
  where T1 is a type-variable:
4553
    T1 extends X<T1> declared in method <T1>dupT()
4554
1 error
4555
 */
4112
	}
4556
	}
4113
	// more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897
4557
	// more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897
4114
	public void test054d() {
4558
	public void test054d() {
4115
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
4559
		this.runNegativeTest(
4116
		this.runConformTest(
4117
			new String[] {
4560
			new String[] {
4118
				"X.java",
4561
				"X.java",
4119
				"public class X {\n" +
4562
				"public class X {\n" +
Lines 4124-4131 Link Here
4124
				"}\n" +
4567
				"}\n" +
4125
				"class A<T> {}\n",
4568
				"class A<T> {}\n",
4126
			},
4569
			},
4127
			""
4570
			"----------\n" + 
4128
		);
4571
			"1. ERROR in X.java (at line 2)\n" + 
4572
			"	<T> T a(A<T> t) {return null;}\n" + 
4573
			"	      ^^^^^^^^^\n" + 
4574
			"Method a(A<T>) has the same erasure a(A<T>) as another method in type X\n" + 
4575
			"----------\n" + 
4576
			"2. ERROR in X.java (at line 3)\n" + 
4577
			"	<T> String a(A<Object> o) {return null;}\n" + 
4578
			"	           ^^^^^^^^^^^^^^\n" + 
4579
			"Method a(A<Object>) has the same erasure a(A<T>) as another method in type X\n" + 
4580
			"----------\n" + 
4581
			"3. ERROR in X.java (at line 4)\n" + 
4582
			"	<T> T aa(A<T> t) {return null;}\n" + 
4583
			"	      ^^^^^^^^^^\n" + 
4584
			"Method aa(A<T>) has the same erasure aa(A<T>) as another method in type X\n" + 
4585
			"----------\n" + 
4586
			"4. ERROR in X.java (at line 5)\n" + 
4587
			"	String aa(A<Object> o) {return null;}\n" + 
4588
			"	       ^^^^^^^^^^^^^^^\n" + 
4589
			"Method aa(A<Object>) has the same erasure aa(A<T>) as another method in type X\n" + 
4590
			"----------\n"
4591
		);
4592
/* javac 7
4593
X.java:3: name clash: <T#1>a(A<Object>) and <T#2>a(A<T#2>) have the same erasure
4594
4595
        <T> String a(A<Object> o) {return null;}
4596
                   ^
4597
  where T#1,T#2 are type-variables:
4598
    T#1 extends Object declared in method <T#1>a(A<Object>)
4599
    T#2 extends Object declared in method <T#2>a(A<T#2>)
4600
X.java:5: name clash: aa(A<Object>) and <T>aa(A<T>) have the same erasure
4601
        String aa(A<Object> o) {return null;}
4602
               ^
4603
  where T is a type-variable:
4604
    T extends Object declared in method <T>aa(A<T>)
4605
2 errors
4606
 */
4129
	}
4607
	}
4130
4608
4131
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=95933
4609
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=95933
Lines 4233-4278 Link Here
4233
	}
4711
	}
4234
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=94898
4712
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=94898
4235
	public void test058a() {
4713
	public void test058a() {
4236
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
4237
		this.runNegativeTest(
4714
		this.runNegativeTest(
4238
			new String[] {
4715
			new String[] {
4239
				"X.java",
4716
				"X.java",
4240
				"public class X<A> {\n" +
4717
				"public class X<A> {\n" +
4241
				"   void test() {\n" +
4718
				"	void test() {\n" +
4242
				"   	new X<Object>().foo(\"X\");\n" +
4719
				"		new X<Object>().foo(\"X\");\n" +
4243
				"   	new X<Object>().foo2(\"X\");\n" +
4720
				"		new X<Object>().foo2(\"X\");\n" +
4244
				"   }\n" +
4721
				"	}\n" +
4245
				"	<T> T foo(T t) {return null;}\n" +
4722
				"	<T> T foo(T t) {return null;}\n" +
4246
				"	void foo(A a) {}\n" +
4723
				"	void foo(A a) {}\n" +
4247
				"	<T> T foo2(T t) {return null;}\n" +
4724
				"	<T> T foo2(T t) {return null;}\n" +
4248
				"	<T> void foo2(A a) {}\n" +
4725
				"	<T> void foo2(A a) {}\n" +
4249
				"}\n"
4726
				"}\n"
4250
			},
4727
			},
4251
			"----------\n" +
4728
			"----------\n" + 
4252
			"1. ERROR in X.java (at line 3)\r\n" +
4729
			"1. ERROR in X.java (at line 6)\n" + 
4253
			"	new X<Object>().foo(\"X\");\r\n" +
4730
			"	<T> T foo(T t) {return null;}\n" + 
4254
			"	                ^^^\n" +
4731
			"	      ^^^^^^^^\n" + 
4255
			"The method foo(String) is ambiguous for the type X<Object>\n" +
4732
			"Method foo(T) has the same erasure foo(Object) as another method in type X<A>\n" + 
4256
			"----------\n" +
4733
			"----------\n" + 
4257
			"2. ERROR in X.java (at line 4)\r\n" +
4734
			"2. ERROR in X.java (at line 7)\n" + 
4258
			"	new X<Object>().foo2(\"X\");\r\n" +
4735
			"	void foo(A a) {}\n" + 
4259
			"	                ^^^^\n" +
4736
			"	     ^^^^^^^^\n" + 
4260
			"The method foo2(String) is ambiguous for the type X<Object>\n" +
4737
			"Method foo(A) has the same erasure foo(Object) as another method in type X<A>\n" + 
4261
			"----------\n"
4738
			"----------\n" + 
4262
			// both references are ambiguous
4739
			"3. ERROR in X.java (at line 8)\n" + 
4263
		);
4740
			"	<T> T foo2(T t) {return null;}\n" + 
4741
			"	      ^^^^^^^^^\n" + 
4742
			"Method foo2(T) has the same erasure foo2(Object) as another method in type X<A>\n" + 
4743
			"----------\n" + 
4744
			"4. ERROR in X.java (at line 9)\n" + 
4745
			"	<T> void foo2(A a) {}\n" + 
4746
			"	         ^^^^^^^^^\n" + 
4747
			"Method foo2(A) has the same erasure foo2(Object) as another method in type X<A>\n" + 
4748
			"----------\n"
4749
		);
4750
/* javac 7
4751
X.java:7: name clash: foo(A) and <T>foo(T) have the same erasure
4752
        void foo(A a) {}
4753
             ^
4754
  where A,T are type-variables:
4755
    A extends Object declared in class X
4756
    T extends Object declared in method <T>foo(T)
4757
X.java:9: name clash: <T#1>foo2(A) and <T#3>foo2(T#3) have the same erasure
4758
        <T> void foo2(A a) {}
4759
                 ^
4760
  where T#1,A,T#3 are type-variables:
4761
    T#1 extends Object declared in method <T#1>foo2(A)
4762
    A extends Object declared in class X
4763
    T#3 extends Object declared in method <T#3>foo2(T#3)
4764
2 errors
4765
 */
4264
	}
4766
	}
4265
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=94898
4767
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=94898
4266
	public void test058b() {
4768
	public void test058b() {
4267
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
4268
		this.runNegativeTest(
4769
		this.runNegativeTest(
4269
			new String[] {
4770
			new String[] {
4270
				"X.java",
4771
				"X.java",
4271
				"public class X<A> extends Y<A> {\n" +
4772
				"public class X<A> extends Y<A> {\n" +
4272
				"   void test() {\n" +
4773
				"	void test() {\n" +
4273
				"   	new X<Object>().foo(\"X\");\n" +
4774
				"		new X<Object>().foo(\"X\");\n" +
4274
				"   	new X<Object>().foo2(\"X\");\n" +
4775
				"		new X<Object>().foo2(\"X\");\n" +
4275
				"   }\n" +
4776
				"	}\n" +
4276
				"	<T> T foo(T t) {return null;}\n" +
4777
				"	<T> T foo(T t) {return null;}\n" +
4277
				"	<T> T foo2(T t) {return null;}\n" +
4778
				"	<T> T foo2(T t) {return null;}\n" +
4278
				"}\n" +
4779
				"}\n" +
Lines 4282-4299 Link Here
4282
				"}"
4783
				"}"
4283
			},
4784
			},
4284
			"----------\n" +
4785
			"----------\n" +
4285
			"1. ERROR in X.java (at line 3)\r\n" +
4786
			"1. ERROR in X.java (at line 3)\n" + 
4286
			"	new X<Object>().foo(\"X\");\r\n" +
4787
			"	new X<Object>().foo(\"X\");\n" + 
4287
			"	                ^^^\n" +
4788
			"	                ^^^\n" + 
4288
			"The method foo(String) is ambiguous for the type X<Object>\n" +
4789
			"The method foo(String) is ambiguous for the type X<Object>\n" + 
4289
			"----------\n" +
4790
			"----------\n" + 
4290
			"2. ERROR in X.java (at line 4)\r\n" +
4791
			"2. ERROR in X.java (at line 4)\n" + 
4291
			"	new X<Object>().foo2(\"X\");\r\n" +
4792
			"	new X<Object>().foo2(\"X\");\n" + 
4292
			"	                ^^^^\n" +
4793
			"	                ^^^^\n" + 
4293
			"The method foo2(String) is ambiguous for the type X<Object>\n" +
4794
			"The method foo2(String) is ambiguous for the type X<Object>\n" + 
4294
			"----------\n"
4795
			"----------\n" + 
4295
			// both references are ambiguous
4796
			"3. ERROR in X.java (at line 6)\n" + 
4296
		);
4797
			"	<T> T foo(T t) {return null;}\n" + 
4798
			"	      ^^^^^^^^\n" + 
4799
			"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" + 
4800
			"----------\n" + 
4801
			"4. ERROR in X.java (at line 7)\n" + 
4802
			"	<T> T foo2(T t) {return null;}\n" + 
4803
			"	      ^^^^^^^^^\n" + 
4804
			"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" + 
4805
			"----------\n"
4806
		);
4807
/* javac 7
4808
X.java:3: reference to foo is ambiguous, both method foo(A) in Y and method <T>foo(T) in X match
4809
                new X<Object>().foo("X");
4810
                               ^
4811
  where A,T are type-variables:
4812
    A extends Object declared in class Y
4813
    T extends Object declared in method <T>foo(T)
4814
X.java:4: reference to foo2 is ambiguous, both method <T#1>foo2(A) in Y and method <T#3>foo2(T#3) in X match
4815
                new X<Object>().foo2("X");
4816
                               ^
4817
  where T#1,A,T#3 are type-variables:
4818
    T#1 extends Object declared in method <T#1>foo2(A)
4819
    A extends Object declared in class Y
4820
    T#3 extends Object declared in method <T#3>foo2(T#3)
4821
X.java:6: name clash: <T>foo(T) in X and foo(A) in Y have the same erasure, yet neither overrides the other
4822
        <T> T foo(T t) {return null;}
4823
              ^
4824
  where T,A are type-variables:
4825
    T extends Object declared in method <T>foo(T)
4826
    A extends Object declared in class Y
4827
X.java:7: name clash: <T#1>foo2(T#1) in X and <T#2>foo2(A) in Y have the same erasure, yet neither overrides the other
4828
        <T> T foo2(T t) {return null;}
4829
              ^
4830
  where T#1,T#2,A are type-variables:
4831
    T#1 extends Object declared in method <T#1>foo2(T#1)
4832
    T#2 extends Object declared in method <T#2>foo2(A)
4833
    A extends Object declared in class Y
4834
4 errors
4835
 */
4297
	}
4836
	}
4298
4837
4299
	public void test059() {
4838
	public void test059() {
Lines 6228-6234 Link Here
6228
6767
6229
// name conflict
6768
// name conflict
6230
public void test101() {
6769
public void test101() {
6231
	if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
6232
	this.runNegativeTest(
6770
	this.runNegativeTest(
6233
		new String[] {
6771
		new String[] {
6234
			"X.java",
6772
			"X.java",
Lines 6250-6265 Link Here
6250
			"    }\n" +
6788
			"    }\n" +
6251
			"}"
6789
			"}"
6252
		},
6790
		},
6253
		"----------\n" +
6791
		"----------\n" + 
6254
		"1. ERROR in X.java (at line 11)\n" +
6792
		"1. ERROR in X.java (at line 3)\n" + 
6255
		"	Integer getX(List<Integer> l) {\n" +
6793
		"	Integer getX(List<Integer> l) {\n" + 
6256
		"	        ^^^^^^^^^^^^^^^^^^^^^\n" +
6794
		"	        ^^^^^^^^^^^^^^^^^^^^^\n" + 
6257
		"Duplicate method getX(List<Integer>) in type Y\n" +
6795
		"Method getX(List<Integer>) has the same erasure getX(List<E>) as another method in type X\n" + 
6258
		"----------\n" +
6796
		"----------\n" + 
6259
		"2. ERROR in X.java (at line 14)\n" +
6797
		"2. ERROR in X.java (at line 6)\n" + 
6260
		"	String getX(List<Integer> l) {\n" +
6798
		"	String getX(List<String> l) {\n" + 
6261
		"	       ^^^^^^^^^^^^^^^^^^^^^\n" +
6799
		"	       ^^^^^^^^^^^^^^^^^^^^\n" + 
6262
		"Duplicate method getX(List<Integer>) in type Y\n" +
6800
		"Method getX(List<String>) has the same erasure getX(List<E>) as another method in type X\n" + 
6801
		"----------\n" + 
6802
		"3. ERROR in X.java (at line 11)\n" + 
6803
		"	Integer getX(List<Integer> l) {\n" + 
6804
		"	        ^^^^^^^^^^^^^^^^^^^^^\n" + 
6805
		"Duplicate method getX(List<Integer>) in type Y\n" + 
6806
		"----------\n" + 
6807
		"4. ERROR in X.java (at line 14)\n" + 
6808
		"	String getX(List<Integer> l) {\n" + 
6809
		"	       ^^^^^^^^^^^^^^^^^^^^^\n" + 
6810
		"Duplicate method getX(List<Integer>) in type Y\n" + 
6263
		"----------\n"
6811
		"----------\n"
6264
	);
6812
	);
6265
}
6813
}
Lines 7313-7320 Link Here
7313
}
7861
}
7314
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=202830
7862
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=202830
7315
public void test120a() {
7863
public void test120a() {
7316
	if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
7864
	this.runNegativeTest(
7317
	this.runConformTest(
7318
		new String[] {
7865
		new String[] {
7319
			"Bar.java",
7866
			"Bar.java",
7320
			"class Foo<V, E> {\n" +
7867
			"class Foo<V, E> {\n" +
Lines 7323-7329 Link Here
7323
			"}\n" +
7870
			"}\n" +
7324
			"public class Bar<V,E> extends Foo<V,E> {}"
7871
			"public class Bar<V,E> extends Foo<V,E> {}"
7325
		},
7872
		},
7326
		""
7873
		"----------\n" + 
7874
		"1. ERROR in Bar.java (at line 2)\n" + 
7875
		"	int getThing(V v) { return 1; }\n" + 
7876
		"	    ^^^^^^^^^^^^^\n" + 
7877
		"Method getThing(V) has the same erasure getThing(Object) as another method in type Foo<V,E>\n" + 
7878
		"----------\n" + 
7879
		"2. ERROR in Bar.java (at line 3)\n" + 
7880
		"	boolean getThing(E e) { return true; }\n" + 
7881
		"	        ^^^^^^^^^^^^^\n" + 
7882
		"Method getThing(E) has the same erasure getThing(Object) as another method in type Foo<V,E>\n" + 
7883
		"----------\n"
7327
	);
7884
	);
7328
}
7885
}
7329
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=173477
7886
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=173477
Lines 9013-9019 Link Here
9013
9570
9014
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=251091
9571
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=251091
9015
public void test177() {
9572
public void test177() {
9016
	if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) { // see test187()
9573
	if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_6) { // see test187()
9017
		this.runNegativeTest(
9574
		this.runNegativeTest(
9018
			new String[] {
9575
			new String[] {
9019
				"X.java",
9576
				"X.java",
Lines 9058-9078 Link Here
9058
			"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" + 
9615
			"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" + 
9059
			"----------\n"
9616
			"----------\n"
9060
		);
9617
		);
9061
	} else if (new CompilerOptions(getCompilerOptions()).sourceLevel == ClassFileConstants.JDK1_6) {
9062
		this.runConformTest(
9063
			new String[] {
9064
				"X.java",
9065
				"import java.util.*;\n" +
9066
				"interface I { I foo(Collection<?> c); }\n" +
9067
				"class A extends LinkedHashMap {\n" +
9068
				"	public A foo(Collection c) { return this; }\n" +
9069
				"}\n" +
9070
				"class X extends A implements I {\n" +
9071
				"	@Override public X foo(Collection<?> c) { return this; }\n" +
9072
				"}"
9073
			},
9074
			""
9075
		);
9076
	} else {
9618
	} else {
9077
		this.runNegativeTest(
9619
		this.runNegativeTest(
9078
			new String[] {
9620
			new String[] {
Lines 9086-9116 Link Here
9086
				"	@Override public X foo(Collection<?> c) { return this; }\n" +
9628
				"	@Override public X foo(Collection<?> c) { return this; }\n" +
9087
				"}"
9629
				"}"
9088
			},
9630
			},
9089
			"----------\n" +
9631
			"----------\n" + 
9090
			"1. WARNING in X.java (at line 3)\n" +
9632
			"1. WARNING in X.java (at line 3)\n" + 
9091
			"	class A extends LinkedHashMap {\n" +
9633
			"	class A extends LinkedHashMap {\n" + 
9092
			"	      ^\n" +
9634
			"	      ^\n" + 
9093
			"The serializable class A does not declare a static final serialVersionUID field of type long\n" +
9635
			"The serializable class A does not declare a static final serialVersionUID field of type long\n" + 
9094
			"----------\n" +
9636
			"----------\n" + 
9095
			"2. WARNING in X.java (at line 3)\n" +
9637
			"2. WARNING in X.java (at line 3)\n" + 
9096
			"	class A extends LinkedHashMap {\n" +
9638
			"	class A extends LinkedHashMap {\n" + 
9097
			"	                ^^^^^^^^^^^^^\n" +
9639
			"	                ^^^^^^^^^^^^^\n" + 
9098
			"LinkedHashMap is a raw type. References to generic type LinkedHashMap<K,V> should be parameterized\n" +
9640
			"LinkedHashMap is a raw type. References to generic type LinkedHashMap<K,V> should be parameterized\n" + 
9099
			"----------\n" +
9641
			"----------\n" + 
9100
			"3. WARNING in X.java (at line 4)\n" +
9642
			"3. WARNING in X.java (at line 4)\n" + 
9101
			"	public A foo(Collection c) { return this; }\n" +
9643
			"	public A foo(Collection c) { return this; }\n" + 
9102
			"	             ^^^^^^^^^^\n" +
9644
			"	             ^^^^^^^^^^\n" + 
9103
			"Collection is a raw type. References to generic type Collection<E> should be parameterized\n" +
9645
			"Collection is a raw type. References to generic type Collection<E> should be parameterized\n" + 
9104
			"----------\n" +
9646
			"----------\n" + 
9105
			"4. WARNING in X.java (at line 6)\n" +
9647
			"4. ERROR in X.java (at line 6)\n" + 
9106
			"	class X extends A implements I {\n" +
9648
			"	class X extends A implements I {\n" + 
9107
			"	      ^\n" +
9649
			"	      ^\n" + 
9108
			"The serializable class X does not declare a static final serialVersionUID field of type long\n" +
9650
			"Name clash: The method foo(Collection<?>) of type I has the same erasure as foo(Collection) of type A but does not override it\n" + 
9109
			"----------\n" +
9651
			"----------\n" + 
9110
			"5. ERROR in X.java (at line 7)\n" +
9652
			"5. WARNING in X.java (at line 6)\n" + 
9111
			"	@Override public X foo(Collection<?> c) { return this; }\n" +
9653
			"	class X extends A implements I {\n" + 
9112
			"	                   ^^^^^^^^^^^^^^^^^^^^\n" +
9654
			"	      ^\n" + 
9113
			"The method foo(Collection<?>) of type X must override a superclass method\n" +
9655
			"The serializable class X does not declare a static final serialVersionUID field of type long\n" + 
9656
			"----------\n" + 
9657
			"6. ERROR in X.java (at line 7)\n" + 
9658
			"	@Override public X foo(Collection<?> c) { return this; }\n" + 
9659
			"	                   ^^^^^^^^^^^^^^^^^^^^\n" + 
9660
			"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" + 
9661
			"----------\n" + 
9662
			"7. ERROR in X.java (at line 7)\n" + 
9663
			"	@Override public X foo(Collection<?> c) { return this; }\n" + 
9664
			"	                   ^^^^^^^^^^^^^^^^^^^^\n" + 
9665
			"The method foo(Collection<?>) of type X must override a superclass method\n" + 
9114
			"----------\n"
9666
			"----------\n"
9115
		);
9667
		);
9116
	}
9668
	}
Lines 9583-9589 Link Here
9583
			"    int f(List<String> l) {return 0;}\n" +
10135
			"    int f(List<String> l) {return 0;}\n" +
9584
			"}\n" +
10136
			"}\n" +
9585
			"class Y extends X {\n" +
10137
			"class Y extends X {\n" +
9586
			"    double f(List<Integer> l) {return 0;}\n" +
10138
			"    double f(List<Integer> l) {return 0;}\n" +// name clash in 7
9587
			"}\n" +
10139
			"}\n" +
9588
			"interface I {\n" +
10140
			"interface I {\n" +
9589
			"	double f(List<Integer> l);\n" +
10141
			"	double f(List<Integer> l);\n" +
Lines 9591-9622 Link Here
9591
			"abstract class Z extends X implements I {}\n" +
10143
			"abstract class Z extends X implements I {}\n" +
9592
			"class XX {\n" +
10144
			"class XX {\n" +
9593
			"    int f(List<String> l) {return 0;}\n" +
10145
			"    int f(List<String> l) {return 0;}\n" +
9594
    			"double f(List<Integer> l) {return 0;}\n" +
10146
    			"double f(List<Integer> l) {return 0;}\n" +// name clash in 1.5 & 7
9595
			"}"
10147
			"}"
9596
		},
10148
		},
9597
		new CompilerOptions(getCompilerOptions()).complianceLevel < ClassFileConstants.JDK1_7
10149
		"----------\n" + 
9598
			? ""
10150
		"1. ERROR in X.java (at line 6)\n" + 
9599
			: "----------\n" + 
10151
		"	double f(List<Integer> l) {return 0;}\n" + 
9600
			"1. ERROR in X.java (at line 6)\n" + 
10152
		"	       ^^^^^^^^^^^^^^^^^^\n" + 
9601
			"	double f(List<Integer> l) {return 0;}\n" + 
10153
		"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" + 
9602
			"	       ^^^^^^^^^^^^^^^^^^\n" + 
10154
		"----------\n" + 
9603
			"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" + 
10155
		"2. ERROR in X.java (at line 11)\n" + 
9604
			"----------\n" + 
10156
		"	abstract class Z extends X implements I {}\n" + 
9605
			"2. ERROR in X.java (at line 11)\n" + 
10157
		"	               ^\n" + 
9606
			"	abstract class Z extends X implements I {}\n" + 
10158
		"Name clash: The method f(List<String>) of type X has the same erasure as f(List<Integer>) of type I but does not override it\n" + 
9607
			"	               ^\n" + 
10159
		"----------\n" + 
9608
			"Name clash: The method f(List<String>) of type X has the same erasure as f(List<Integer>) of type I but does not override it\n" + 
10160
		"3. ERROR in X.java (at line 13)\n" + 
9609
			"----------\n" + 
10161
		"	int f(List<String> l) {return 0;}\n" + 
9610
			"3. ERROR in X.java (at line 13)\n" + 
10162
		"	    ^^^^^^^^^^^^^^^^^\n" + 
9611
			"	int f(List<String> l) {return 0;}\n" + 
10163
		"Method f(List<String>) has the same erasure f(List<E>) as another method in type XX\n" + 
9612
			"	    ^^^^^^^^^^^^^^^^^\n" + 
10164
		"----------\n" + 
9613
			"Method f(List<String>) has the same erasure f(List<E>) as another method in type XX\n" + 
10165
		"4. ERROR in X.java (at line 14)\n" + 
9614
			"----------\n" + 
10166
		"	double f(List<Integer> l) {return 0;}\n" + 
9615
			"4. ERROR in X.java (at line 14)\n" + 
10167
		"	       ^^^^^^^^^^^^^^^^^^\n" + 
9616
			"	double f(List<Integer> l) {return 0;}\n" + 
10168
		"Method f(List<Integer>) has the same erasure f(List<E>) as another method in type XX\n" + 
9617
			"	       ^^^^^^^^^^^^^^^^^^\n" + 
10169
		"----------\n"
9618
			"Method f(List<Integer>) has the same erasure f(List<E>) as another method in type XX\n" + 
9619
			"----------\n"
9620
	);
10170
	);
9621
}
10171
}
9622
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=279836
10172
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=279836
Lines 10036-10039 Link Here
10036
		JavacTestOptions.SKIP
10586
		JavacTestOptions.SKIP
10037
	);
10587
	);
10038
}
10588
}
10589
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=285088
10590
public void test200() {
10591
	this.runNegativeTest(
10592
		new String[] {
10593
			"X.java",
10594
			"import java.util.Collection;\n" +
10595
			"class X {\n" +
10596
			"	int foo(Collection bar) { return 0; }\n" +
10597
			"	double foo(Collection<String> bar) {return 0; }\n" +
10598
			"}"
10599
		},
10600
		"----------\n" + 
10601
		"1. ERROR in X.java (at line 3)\n" + 
10602
		"	int foo(Collection bar) { return 0; }\n" + 
10603
		"	    ^^^^^^^^^^^^^^^^^^^\n" + 
10604
		"Method foo(Collection) has the same erasure foo(Collection<E>) as another method in type X\n" + 
10605
		"----------\n" + 
10606
		"2. WARNING in X.java (at line 3)\n" + 
10607
		"	int foo(Collection bar) { return 0; }\n" + 
10608
		"	        ^^^^^^^^^^\n" + 
10609
		"Collection is a raw type. References to generic type Collection<E> should be parameterized\n" + 
10610
		"----------\n" + 
10611
		"3. ERROR in X.java (at line 4)\n" + 
10612
		"	double foo(Collection<String> bar) {return 0; }\n" + 
10613
		"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
10614
		"Method foo(Collection<String>) has the same erasure foo(Collection<E>) as another method in type X\n" + 
10615
		"----------\n"
10616
	);
10617
/* javac 7
10618
X.java:4: foo(Collection) is already defined in X
10619
        double foo(Collection<String> bar) {return 0; }
10620
               ^
10621
1 error
10622
 */
10623
}
10039
}
10624
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java (-157 / +342 lines)
Lines 17606-17613 Link Here
17606
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=87956
17606
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=87956
17607
	public void test0561() {
17607
	public void test0561() {
17608
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
17608
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
17609
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return;
17609
		this.runNegativeTest(
17610
		this.runConformTest(
17611
			new String[] {
17610
			new String[] {
17612
				"X.java",
17611
				"X.java",
17613
				"public class X {\n" +
17612
				"public class X {\n" +
Lines 17617-17625 Link Here
17617
				"}\n" +
17616
				"}\n" +
17618
				"class A<T> {}\n",
17617
				"class A<T> {}\n",
17619
			},
17618
			},
17620
			""
17619
			"----------\n" + 
17620
			"1. ERROR in X.java (at line 2)\n" + 
17621
			"	void foo(A<String> a) {}\n" + 
17622
			"	     ^^^^^^^^^^^^^^^^\n" + 
17623
			"Method foo(A<String>) has the same erasure foo(A<T>) as another method in type X\n" + 
17624
			"----------\n" + 
17625
			"2. ERROR in X.java (at line 3)\n" + 
17626
			"	Object foo(A<Integer> a) { return null; }\n" + 
17627
			"	       ^^^^^^^^^^^^^^^^^\n" + 
17628
			"Method foo(A<Integer>) has the same erasure foo(A<T>) as another method in type X\n" + 
17629
			"----------\n" + 
17630
			"3. ERROR in X.java (at line 4)\n" + 
17631
			"	void test(A<Integer> a) { foo(a); }\n" + 
17632
			"	                          ^^^\n" + 
17633
			"The method foo(A<String>) in the type X is not applicable for the arguments (A<Integer>)\n" + 
17634
			"----------\n"
17621
		);
17635
		);
17622
		this.runConformTest(
17636
/* javac 7
17637
X.java:3: name clash: foo(A<Integer>) and foo(A<String>) have the same erasure
17638
        Object foo(A<Integer> a) { return null; }
17639
               ^
17640
X.java:4: method foo in class X cannot be applied to given types
17641
        void test(A<Integer> a) { foo(a); }
17642
                                  ^
17643
  required: A<String>
17644
  found: A<Integer>
17645
2 errors
17646
 */
17647
		this.runNegativeTest(
17623
			new String[] {
17648
			new String[] {
17624
				"X.java",
17649
				"X.java",
17625
				"public class X {\n" +
17650
				"public class X {\n" +
Lines 17629-17635 Link Here
17629
				"}\n" +
17654
				"}\n" +
17630
				"class A<T> {}\n",
17655
				"class A<T> {}\n",
17631
			},
17656
			},
17632
			""
17657
			"----------\n" + 
17658
			"1. ERROR in X.java (at line 2)\n" + 
17659
			"	Number foo(A<String> a) { return null; }\n" + 
17660
			"	       ^^^^^^^^^^^^^^^^\n" + 
17661
			"Method foo(A<String>) has the same erasure foo(A<T>) as another method in type X\n" + 
17662
			"----------\n" + 
17663
			"2. ERROR in X.java (at line 3)\n" + 
17664
			"	Integer foo(A<Integer> a) { return null; }\n" + 
17665
			"	        ^^^^^^^^^^^^^^^^^\n" + 
17666
			"Method foo(A<Integer>) has the same erasure foo(A<T>) as another method in type X\n" + 
17667
			"----------\n" + 
17668
			"3. ERROR in X.java (at line 4)\n" + 
17669
			"	void test(A<Integer> a) { foo(a); }\n" + 
17670
			"	                          ^^^\n" + 
17671
			"The method foo(A<String>) in the type X is not applicable for the arguments (A<Integer>)\n" + 
17672
			"----------\n"
17673
/* javac 7
17674
X.java:3: name clash: foo(A<Integer>) and foo(A<String>) have the same erasure
17675
        Integer foo(A<Integer> a) { return null; }
17676
                ^
17677
X.java:4: method foo in class X cannot be applied to given types
17678
        void test(A<Integer> a) { foo(a); }
17679
                                  ^
17680
  required: A<String>
17681
  found: A<Integer>
17682
2 errors
17683
 */
17633
		);
17684
		);
17634
	}
17685
	}
17635
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=87550
17686
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=87550
Lines 17940-17946 Link Here
17940
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation
17991
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation
17941
	public void test0574() {
17992
	public void test0574() {
17942
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
17993
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
17943
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return;
17944
		this.runNegativeTest(
17994
		this.runNegativeTest(
17945
			new String[] {
17995
			new String[] {
17946
				"X.java",
17996
				"X.java",
Lines 17957-17978 Link Here
17957
				"	}\n" +
18007
				"	}\n" +
17958
				"}\n"
18008
				"}\n"
17959
			},
18009
			},
17960
			"----------\n" +
18010
			"----------\n" + 
17961
			"1. WARNING in X.java (at line 6)\n" +
18011
			"1. WARNING in X.java (at line 6)\n" + 
17962
			"	<T extends Integer> T foo(Object o) {  return null; } // ok\n" +
18012
			"	<T extends Integer> T foo(Object o) {  return null; } // ok\n" + 
17963
			"	           ^^^^^^^\n" +
18013
			"	           ^^^^^^^\n" + 
17964
			"The type parameter T should not be bounded by the final type Integer. Final types cannot be further extended\n" +
18014
			"The type parameter T should not be bounded by the final type Integer. Final types cannot be further extended\n" + 
17965
			"----------\n" +
18015
			"----------\n" + 
17966
			"2. WARNING in X.java (at line 7)\n" +
18016
			"2. ERROR in X.java (at line 6)\n" + 
17967
			"	<T extends String> T foo(Object o) {  return null; } // ok\n" +
18017
			"	<T extends Integer> T foo(Object o) {  return null; } // ok\n" + 
17968
			"	           ^^^^^^\n" +
18018
			"	                      ^^^^^^^^^^^^^\n" + 
17969
			"The type parameter T should not be bounded by the final type String. Final types cannot be further extended\n" +
18019
			"Duplicate method foo(Object) in type X.C2\n" + 
17970
			"----------\n" +
18020
			"----------\n" + 
17971
			"3. ERROR in X.java (at line 10)\n" +
18021
			"3. WARNING in X.java (at line 7)\n" + 
17972
			"	new X().new C2().foo((List<String>) null);\n" +
18022
			"	<T extends String> T foo(Object o) {  return null; } // ok\n" + 
17973
			"	                 ^^^\n" +
18023
			"	           ^^^^^^\n" + 
17974
			"The method foo(Object) is ambiguous for the type X.C2\n" +
18024
			"The type parameter T should not be bounded by the final type String. Final types cannot be further extended\n" + 
17975
			"----------\n");
18025
			"----------\n" + 
18026
			"4. ERROR in X.java (at line 7)\n" + 
18027
			"	<T extends String> T foo(Object o) {  return null; } // ok\n" + 
18028
			"	                     ^^^^^^^^^^^^^\n" + 
18029
			"Duplicate method foo(Object) in type X.C2\n" + 
18030
			"----------\n"
18031
		);
18032
/*
18033
X.java:6: name clash: <T#1>foo(Object) and <T#2>foo(Object) have the same erasure
18034
                <T extends String> T foo(Object o) {  return null; } // ok
18035
                                     ^
18036
  where T#1,T#2 are type-variables:
18037
    T#1 extends String declared in method <T#1>foo(Object)
18038
    T#2 extends Integer declared in method <T#2>foo(Object)
18039
1 error
18040
 */
17976
	}
18041
	}
17977
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=84496 - variation with field ref
18042
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=84496 - variation with field ref
17978
	public void test0575() {
18043
	public void test0575() {
Lines 22338-22391 Link Here
22338
}
22403
}
22339
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=97219
22404
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=97219
22340
public void test0706() {
22405
public void test0706() {
22341
	if (this.complianceLevel < ClassFileConstants.JDK1_7) {
22342
		this.runConformTest(
22343
			new String[] {
22344
				"X.java",
22345
				"public class X {\n" +
22346
				"	void foo() {\n" +
22347
				"		BB bb = new BB();\n" +
22348
				"		bb.<Object>test();\n" +
22349
				"		((AA<CC>) bb).test();\n" +
22350
				"	}\n" +
22351
				"}\n" +
22352
				"class AA<T> { AA<Object> test() {return null;} }\n" +
22353
				"class BB extends AA<CC> { <U> BB test() {return null;} }\n" +
22354
				"class CC {}\n",
22355
			},
22356
			"");
22357
		return;
22358
	}
22359
	this.runNegativeTest(
22406
	this.runNegativeTest(
22360
			new String[] {
22407
		new String[] {
22361
				"X.java",
22408
			"X.java",
22362
				"public class X {\n" +
22409
			"public class X {\n" +
22363
				"	void foo() {\n" +
22410
			"	void foo() {\n" +
22364
				"		BB bb = new BB();\n" +
22411
			"		BB bb = new BB();\n" +
22365
				"		bb.<Object>test();\n" +
22412
			"		bb.<Object>test();\n" +
22366
				"		((AA<CC>) bb).test();\n" +
22413
			"		((AA<CC>) bb).test();\n" +
22367
				"	}\n" +
22414
			"	}\n" +
22368
				"}\n" +
22415
			"}\n" +
22369
				"class AA<T> { AA<Object> test() {return null;} }\n" +
22416
			"class AA<T> { AA<Object> test() {return null;} }\n" +
22370
				"class BB extends AA<CC> { <U> BB test() {return null;} }\n" +
22417
			"class BB extends AA<CC> { <U> BB test() {return null;} }\n" +
22371
				"class CC {}\n",
22418
			"class CC {}\n",
22372
			},
22419
		},
22373
			"----------\n" +
22420
		(this.complianceLevel < ClassFileConstants.JDK1_7)
22374
			"1. ERROR in X.java (at line 4)\r\n" +
22421
		? "----------\n" + 
22375
			"	bb.<Object>test();\r\n" +
22422
		"1. ERROR in X.java (at line 9)\n" + 
22376
			"	           ^^^^\n" +
22423
		"	class BB extends AA<CC> { <U> BB test() {return null;} }\n" + 
22377
			"The method test() is ambiguous for the type BB\n" +
22424
		"	                                 ^^^^^^\n" + 
22378
			"----------\n" + 
22425
		"Name clash: The method test() of type BB has the same erasure as test() of type AA<T> but does not override it\n" + 
22379
			"2. ERROR in X.java (at line 9)\n" + 
22426
		"----------\n"
22380
			"	class BB extends AA<CC> { <U> BB test() {return null;} }\n" + 
22427
		: "----------\n" + 
22381
			"	                                 ^^^^^^\n" + 
22428
		"1. ERROR in X.java (at line 4)\n" + 
22382
			"Name clash: The method test() of type BB has the same erasure as test() of type AA<T> but does not override it\n" + 
22429
		"	bb.<Object>test();\n" + 
22383
			"----------\n");
22430
		"	           ^^^^\n" + 
22431
		"The method test() is ambiguous for the type BB\n" + 
22432
		"----------\n" + 
22433
		"2. ERROR in X.java (at line 9)\n" + 
22434
		"	class BB extends AA<CC> { <U> BB test() {return null;} }\n" + 
22435
		"	                                 ^^^^^^\n" + 
22436
		"Name clash: The method test() of type BB has the same erasure as test() of type AA<T> but does not override it\n" + 
22437
		"----------\n"
22438
	);
22439
/*
22440
X.java:4: reference to test is ambiguous, both method test() in AA and method <U>test() in BB match
22441
                bb.<Object>test();
22442
                  ^
22443
  where U is a type-variable:
22444
    U extends Object declared in method <U>test()
22445
X.java:9: name clash: <U>test() in BB and test() in AA have the same erasure, yet neither overrides the other
22446
class BB extends AA<CC> { <U> BB test() {return null;} }
22447
                                 ^
22448
  where U is a type-variable:
22449
    U extends Object declared in method <U>test()
22450
2 errors
22451
 */
22384
}
22452
}
22385
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=97219
22453
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=97219
22386
public void test0706a() {
22454
public void test0706a() {
22387
	// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
22455
	// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
22388
	if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return;
22389
	this.runNegativeTest(
22456
	this.runNegativeTest(
22390
		new String[] {
22457
		new String[] {
22391
			"X.java",
22458
			"X.java",
Lines 22400-22429 Link Here
22400
			"class BB extends AA<CC> { <U> BB test() {return null;} }\n" +
22467
			"class BB extends AA<CC> { <U> BB test() {return null;} }\n" +
22401
			"class CC {}\n",
22468
			"class CC {}\n",
22402
		},
22469
		},
22403
		"----------\n" +
22470
		"----------\n" + 
22404
		"1. ERROR in X.java (at line 4)\n" +
22471
		"1. ERROR in X.java (at line 4)\n" + 
22405
		"	AA<Object> res1 = bb.test();\n" +
22472
		"	AA<Object> res1 = bb.test();\n" + 
22406
		"	                     ^^^^\n" +
22473
		"	                     ^^^^\n" + 
22407
		"The method test() is ambiguous for the type BB\n" +
22474
		"The method test() is ambiguous for the type BB\n" + 
22408
		"----------\n" +
22475
		"----------\n" + 
22409
		"2. WARNING in X.java (at line 5)\n" +
22476
		"2. WARNING in X.java (at line 5)\n" + 
22410
		"	AA res3 = bb.test();\n" +
22477
		"	AA res3 = bb.test();\n" + 
22411
		"	^^\n" +
22478
		"	^^\n" + 
22412
		"AA is a raw type. References to generic type AA<T> should be parameterized\n" +
22479
		"AA is a raw type. References to generic type AA<T> should be parameterized\n" + 
22413
		"----------\n" +
22480
		"----------\n" + 
22414
		"3. ERROR in X.java (at line 5)\n" +
22481
		"3. ERROR in X.java (at line 5)\n" + 
22415
		"	AA res3 = bb.test();\n" +
22482
		"	AA res3 = bb.test();\n" + 
22416
		"	             ^^^^\n" +
22483
		"	             ^^^^\n" + 
22417
		"The method test() is ambiguous for the type BB\n" +
22484
		"The method test() is ambiguous for the type BB\n" + 
22485
		"----------\n" + 
22486
		"4. ERROR in X.java (at line 9)\n" + 
22487
		"	class BB extends AA<CC> { <U> BB test() {return null;} }\n" + 
22488
		"	                                 ^^^^^^\n" + 
22489
		"Name clash: The method test() of type BB has the same erasure as test() of type AA<T> but does not override it\n" + 
22418
		"----------\n"
22490
		"----------\n"
22419
		// 4: reference to test is ambiguous, both method test() in AA<CC> and method <U>test() in BB match
22420
		// 5: reference to test is ambiguous, both method test() in AA<CC> and method <U>test() in BB match
22421
	);
22491
	);
22492
/*
22493
X.java:4: reference to test is ambiguous, both method test() in AA and method <U>test() in BB match
22494
                AA<Object> res1 = bb.test();
22495
                                    ^
22496
  where U is a type-variable:
22497
    U extends Object declared in method <U>test()
22498
X.java:5: reference to test is ambiguous, both method test() in AA and method <U>test() in BB match
22499
                AA res3 = bb.test();
22500
                            ^
22501
  where U is a type-variable:
22502
    U extends Object declared in method <U>test()
22503
X.java:9: name clash: <U>test() in BB and test() in AA have the same erasure, yet neither overrides the other
22504
class BB extends AA<CC> { <U> BB test() {return null;} }
22505
                                 ^
22506
  where U is a type-variable:
22507
    U extends Object declared in method <U>test()
22508
3 errors
22509
 */
22422
}
22510
}
22423
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=97219
22511
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=97219
22424
public void test0706b() {
22512
public void test0706b() {
22425
	// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
22513
	// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
22426
	if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return;
22427
	this.runNegativeTest(
22514
	this.runNegativeTest(
22428
		new String[] {
22515
		new String[] {
22429
			"X.java",
22516
			"X.java",
Lines 22438-22459 Link Here
22438
			"class BB extends AA<CC> { <U> BB test() {return null;} }\n" +
22525
			"class BB extends AA<CC> { <U> BB test() {return null;} }\n" +
22439
			"class CC {}\n",
22526
			"class CC {}\n",
22440
		},
22527
		},
22441
		"----------\n" +
22528
		"----------\n" + 
22442
		"1. ERROR in X.java (at line 4)\n" +
22529
		"1. ERROR in X.java (at line 4)\n" + 
22443
		"	AA<CC> res = bb.test();\n" +
22530
		"	AA<CC> res = bb.test();\n" + 
22444
		"	                ^^^^\n" +
22531
		"	                ^^^^\n" + 
22445
		"The method test() is ambiguous for the type BB\n" +
22532
		"The method test() is ambiguous for the type BB\n" + 
22446
		"----------\n" +
22533
		"----------\n" + 
22447
		"2. ERROR in X.java (at line 5)\n" +
22534
		"2. ERROR in X.java (at line 5)\n" + 
22448
		"	BB res2 = bb.test();\n" +
22535
		"	BB res2 = bb.test();\n" + 
22449
		"	             ^^^^\n" +
22536
		"	             ^^^^\n" + 
22450
		"The method test() is ambiguous for the type BB\n" +
22537
		"The method test() is ambiguous for the type BB\n" + 
22538
		"----------\n" + 
22539
		"3. ERROR in X.java (at line 9)\n" + 
22540
		"	class BB extends AA<CC> { <U> BB test() {return null;} }\n" + 
22541
		"	                                 ^^^^^^\n" + 
22542
		"Name clash: The method test() of type BB has the same erasure as test() of type AA<T> but does not override it\n" + 
22451
		"----------\n"
22543
		"----------\n"
22452
		// 4: reference to test is ambiguous, both method test() in AA<CC> and method <U>test() in BB match
22453
		// 4: incompatible types on the assignment
22454
		// 5: reference to test is ambiguous, both method test() in AA<CC> and method <U>test() in BB match
22455
		// 5: incompatible types on the assignment
22456
	);
22544
	);
22545
/*
22546
X.java:4: reference to test is ambiguous, both method test() in AA and method <U>test() in BB match
22547
                AA<CC> res = bb.test();
22548
                               ^
22549
  where U is a type-variable:
22550
    U extends Object declared in method <U>test()
22551
X.java:4: incompatible types
22552
                AA<CC> res = bb.test();
22553
                                    ^
22554
  required: AA<CC>
22555
  found:    AA<Object>
22556
X.java:5: reference to test is ambiguous, both method test() in AA and method <U>test() in BB match
22557
                BB res2 = bb.test();
22558
                            ^
22559
  where U is a type-variable:
22560
    U extends Object declared in method <U>test()
22561
X.java:5: incompatible types
22562
                BB res2 = bb.test();
22563
                                 ^
22564
  required: BB
22565
  found:    AA<Object>
22566
X.java:9: name clash: <U>test() in BB and test() in AA have the same erasure, yet neither overrides the other
22567
class BB extends AA<CC> { <U> BB test() {return null;} }
22568
                                 ^
22569
  where U is a type-variable:
22570
    U extends Object declared in method <U>test()
22571
5 errors
22572
 */
22457
	this.runNegativeTest(
22573
	this.runNegativeTest(
22458
		new String[] {
22574
		new String[] {
22459
			"X.java",
22575
			"X.java",
Lines 22479-22486 Link Here
22479
		"	          ^^^^^^^^^\n" +
22595
		"	          ^^^^^^^^^\n" +
22480
		"Type mismatch: cannot convert from AA<Object> to BB\n" +
22596
		"Type mismatch: cannot convert from AA<Object> to BB\n" +
22481
		"----------\n"
22597
		"----------\n"
22482
		// incompatible types on both assignments
22483
	);
22598
	);
22599
/*
22600
X.java:4: incompatible types
22601
                AA<CC> res = bb.test();
22602
                                    ^
22603
  required: AA<CC>
22604
  found:    AA<Object>
22605
X.java:5: incompatible types
22606
                BB res2 = bb.test();
22607
                                 ^
22608
  required: BB
22609
  found:    AA<Object>
22610
2 errors
22611
 */
22484
}
22612
}
22485
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=98079
22613
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=98079
22486
public void test0707() {
22614
public void test0707() {
Lines 23610-23637 Link Here
23610
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=100007
23738
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=100007
23611
public void test0748() {
23739
public void test0748() {
23612
	// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
23740
	// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
23613
	if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return;
23614
	this.runNegativeTest(
23741
	this.runNegativeTest(
23615
		new String[] {
23742
		new String[] {
23616
			"X.java",
23743
			"X.java",
23617
			"public class X {\n" +
23744
			"interface Factory<T> {\n" +
23618
			"	static interface Factory<T> {\n" +
23745
			"	<U extends T> U create(Class<U> cl);\n" +
23619
			"		public <U extends T> U create(Class<U> cl);\n" +
23746
			"}\n" +
23620
			"	}\n" +
23747
			"abstract class X implements Factory<byte[]> {\n" +
23621
			"	\n" +
23748
			"	public byte[] create(Class<byte[]> cl) { return null; }\n" +
23622
			"	static class BytesFactory implements Factory<byte[]> {\n" +
23623
			"		public byte[] create(Class<byte[]> cl) {\n" +
23624
			"			return null;\n" +
23625
			"		}\n" +
23626
			"	}\n" +
23627
			"}\n",
23749
			"}\n",
23628
		},
23750
		},
23629
		"----------\n" +
23751
		"----------\n" + 
23630
		"1. ERROR in X.java (at line 6)\r\n" +
23752
		"1. ERROR in X.java (at line 5)\n" + 
23631
		"	static class BytesFactory implements Factory<byte[]> {\r\n" +
23753
		"	public byte[] create(Class<byte[]> cl) { return null; }\n" + 
23632
		"	             ^^^^^^^^^^^^\n" +
23754
		"	              ^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
23633
		"The type X.BytesFactory must implement the inherited abstract method X.Factory<byte[]>.create(Class<U>)\n" +
23755
		"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" + 
23634
		"----------\n");
23756
		"----------\n"
23757
	);
23758
// javac 7 reports the name clash when X subclasses another class or is a concrete type
23635
}
23759
}
23636
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=100149
23760
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=100149
23637
public void test0749() {
23761
public void test0749() {
Lines 40021-40027 Link Here
40021
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=204534
40145
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=204534
40022
public void test1181() {
40146
public void test1181() {
40023
	// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
40147
	// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
40024
	if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return;
40025
	this.runNegativeTest(
40148
	this.runNegativeTest(
40026
		new String[] {
40149
		new String[] {
40027
			"X.java",
40150
			"X.java",
Lines 40029-40083 Link Here
40029
			"	public static <S, T extends Comparable<S>, R extends S & T> R max(T arg1, S arg2) {\n" +
40152
			"	public static <S, T extends Comparable<S>, R extends S & T> R max(T arg1, S arg2) {\n" +
40030
			"		return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" +
40153
			"		return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" +
40031
			"	}\n" +
40154
			"	}\n" +
40032
			"\n" +
40033
			"	public static <T extends Comparable<S>, S, R extends S & Comparable<S>> R max(T arg1, S arg2) {\n" +
40155
			"	public static <T extends Comparable<S>, S, R extends S & Comparable<S>> R max(T arg1, S arg2) {\n" +
40034
			"		return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" +
40156
			"		return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" +
40035
			"	}\n" +
40157
			"	}\n" +
40036
			"\n" +
40037
			"	public static <T extends Comparable<S>, S, R extends Comparable<S>> R max(T arg1, S arg2) {\n" +
40158
			"	public static <T extends Comparable<S>, S, R extends Comparable<S>> R max(T arg1, S arg2) {\n" +
40038
			"		return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" +
40159
			"		return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" +
40039
			"	}\n" +
40160
			"	}\n" +
40040
			"\n" +
40161
			"	public static void main(String[] args) {}\n" +
40041
			"	public static void main(String[] args) {\n" +
40042
			"	}\n" +
40043
			"}\n", // =================
40162
			"}\n", // =================
40044
		},
40163
		},
40045
		"----------\n" +
40164
		"----------\n" + 
40046
		"1. ERROR in X.java (at line 2)\n" +
40165
		"1. ERROR in X.java (at line 2)\n" + 
40047
		"	public static <S, T extends Comparable<S>, R extends S & T> R max(T arg1, S arg2) {\n" +
40166
		"	public static <S, T extends Comparable<S>, R extends S & T> R max(T arg1, S arg2) {\n" + 
40048
		"	                                                         ^\n" +
40167
		"	                                                         ^\n" + 
40049
		"Cannot specify any additional bound T when first bound is a type parameter\n" +
40168
		"Cannot specify any additional bound T when first bound is a type parameter\n" + 
40050
		"----------\n" +
40169
		"----------\n" + 
40051
		"2. ERROR in X.java (at line 2)\n" +
40170
		"2. ERROR in X.java (at line 2)\n" + 
40052
		"	public static <S, T extends Comparable<S>, R extends S & T> R max(T arg1, S arg2) {\n" +
40171
		"	public static <S, T extends Comparable<S>, R extends S & T> R max(T arg1, S arg2) {\n" + 
40053
		"	                                                              ^^^^^^^^^^^^^^^^^^^\n" +
40172
		"	                                                              ^^^^^^^^^^^^^^^^^^^\n" + 
40054
		"Method max(T, S) has the same erasure max(Comparable<T>, Object) as another method in type X\n" +
40173
		"Method max(T, S) has the same erasure max(Comparable<T>, Object) as another method in type X\n" + 
40055
		"----------\n" +
40174
		"----------\n" + 
40056
		"3. WARNING in X.java (at line 3)\n" +
40175
		"3. WARNING in X.java (at line 3)\n" + 
40057
		"	return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" +
40176
		"	return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + 
40058
		"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
40177
		"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
40059
		"Type safety: Unchecked cast from Object to R\n" +
40178
		"Type safety: Unchecked cast from Object to R\n" + 
40060
		"----------\n" +
40179
		"----------\n" + 
40061
		"4. ERROR in X.java (at line 6)\n" +
40180
		"4. ERROR in X.java (at line 5)\n" + 
40062
		"	public static <T extends Comparable<S>, S, R extends S & Comparable<S>> R max(T arg1, S arg2) {\n" +
40181
		"	public static <T extends Comparable<S>, S, R extends S & Comparable<S>> R max(T arg1, S arg2) {\n" + 
40063
		"	                                                         ^^^^^^^^^^\n" +
40182
		"	                                                         ^^^^^^^^^^\n" + 
40064
		"Cannot specify any additional bound Comparable<S> when first bound is a type parameter\n" +
40183
		"Cannot specify any additional bound Comparable<S> when first bound is a type parameter\n" + 
40065
		"----------\n" +
40184
		"----------\n" + 
40066
		"5. ERROR in X.java (at line 6)\n" +
40185
		"5. ERROR in X.java (at line 5)\n" + 
40067
		"	public static <T extends Comparable<S>, S, R extends S & Comparable<S>> R max(T arg1, S arg2) {\n" +
40186
		"	public static <T extends Comparable<S>, S, R extends S & Comparable<S>> R max(T arg1, S arg2) {\n" + 
40068
		"	                                                                          ^^^^^^^^^^^^^^^^^^^\n" +
40187
		"	                                                                          ^^^^^^^^^^^^^^^^^^^\n" + 
40069
		"Method max(T, S) has the same erasure max(Comparable<T>, Object) as another method in type X\n" +
40188
		"Method max(T, S) has the same erasure max(Comparable<T>, Object) as another method in type X\n" + 
40070
		"----------\n" +
40189
		"----------\n" + 
40071
		"6. WARNING in X.java (at line 7)\n" +
40190
		"6. WARNING in X.java (at line 6)\n" + 
40072
		"	return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" +
40191
		"	return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + 
40073
		"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
40192
		"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
40074
		"Type safety: Unchecked cast from Object to R\n" +
40193
		"Type safety: Unchecked cast from Object to R\n" + 
40075
		"----------\n" +
40194
		"----------\n" + 
40076
		"7. WARNING in X.java (at line 11)\n" +
40195
		"7. ERROR in X.java (at line 8)\n" + 
40077
		"	return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" +
40196
		"	public static <T extends Comparable<S>, S, R extends Comparable<S>> R max(T arg1, S arg2) {\n" + 
40078
		"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
40197
		"	                                                                      ^^^^^^^^^^^^^^^^^^^\n" + 
40079
		"Type safety: Unchecked cast from Object to R\n" +
40198
		"Method max(T, S) has the same erasure max(Comparable<T>, Object) as another method in type X\n" + 
40080
		"----------\n");
40199
		"----------\n" + 
40200
		"8. WARNING in X.java (at line 9)\n" + 
40201
		"	return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);\n" + 
40202
		"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
40203
		"Type safety: Unchecked cast from Object to R\n" + 
40204
		"----------\n"
40205
	);
40206
/*
40207
X.java:2: a type variable may not be followed by other bounds
40208
        public static <S, T extends Comparable<S>, R extends S & T> R max(T arg1, S arg2) {
40209
                                                                 ^
40210
X.java:5: a type variable may not be followed by other bounds
40211
        public static <T extends Comparable<S>, S, R extends S & Comparable<S>>
40212
R max(T arg1, S arg2) {
40213
                                                                           ^
40214
X.java:5: name clash: <T#1,S#2,R#3>max(T#1,S#2) and <S#4,T#5,R#6>max(T#5,S#4) have the same erasure
40215
        public static <T extends Comparable<S>, S, R extends S & Comparable<S>>
40216
R max(T arg1, S arg2) {
40217
40218
  ^
40219
  where T#1,S#2,R#3,S#4,T#5,R#6 are type-variables:
40220
    T#1 extends Comparable<S#2> declared in method <T#1,S#2,R#3>max(T#1,S#2)
40221
    S#2 extends Object declared in method <T#1,S#2,R#3>max(T#1,S#2)
40222
    R#3 extends S#2 declared in method <T#1,S#2,R#3>max(T#1,S#2)
40223
    S#4 extends Object declared in method <S#4,T#5,R#6>max(T#5,S#4)
40224
    T#5 extends Comparable<S#4> declared in method <S#4,T#5,R#6>max(T#5,S#4)
40225
    R#6 extends S#4 declared in method <S#4,T#5,R#6>max(T#5,S#4)
40226
X.java:8: name clash: <T#1,S#2,R#3>max(T#1,S#2) and <S#4,T#5,R#6>max(T#5,S#4) have the same erasure
40227
        public static <T extends Comparable<S>, S, R extends Comparable<S>> R max(T arg1, S arg2) {
40228
                                                                              ^
40229
  where T#1,S#2,R#3,S#4,T#5,R#6 are type-variables:
40230
    T#1 extends Comparable<S#2> declared in method <T#1,S#2,R#3>max(T#1,S#2)
40231
    S#2 extends Object declared in method <T#1,S#2,R#3>max(T#1,S#2)
40232
    R#3 extends Comparable<S#2> declared in method <T#1,S#2,R#3>max(T#1,S#2)
40233
    S#4 extends Object declared in method <S#4,T#5,R#6>max(T#5,S#4)
40234
    T#5 extends Comparable<S#4> declared in method <S#4,T#5,R#6>max(T#5,S#4)
40235
    R#6 extends S#4 declared in method <S#4,T#5,R#6>max(T#5,S#4)
40236
X.java:3: warning: [unchecked] unchecked cast
40237
                return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);
40238
                           ^
40239
  required: R
40240
  found:    Object
40241
  where R,S,T are type-variables:
40242
    R extends S declared in method <S,T,R>max(T,S)
40243
    S extends Object declared in method <S,T,R>max(T,S)
40244
    T extends Comparable<S> declared in method <S,T,R>max(T,S)
40245
X.java:6: warning: [unchecked] unchecked cast
40246
                return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);
40247
                           ^
40248
  required: R
40249
  found:    Object
40250
  where R,T,S are type-variables:
40251
    R extends S declared in method <T,S,R>max(T,S)
40252
    T extends Comparable<S> declared in method <T,S,R>max(T,S)
40253
    S extends Object declared in method <T,S,R>max(T,S)
40254
X.java:9: warning: [unchecked] unchecked cast
40255
                return (R) ((arg1.compareTo(arg2) > 0) ? arg1 : arg2);
40256
                           ^
40257
  required: R
40258
  found:    Object
40259
  where R,T,S are type-variables:
40260
    R extends Comparable<S> declared in method <T,S,R>max(T,S)
40261
    T extends Comparable<S> declared in method <T,S,R>max(T,S)
40262
    S extends Object declared in method <T,S,R>max(T,S)
40263
4 errors
40264
3 warnings
40265
 */
40081
}
40266
}
40082
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=204536
40267
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=204536
40083
public void test1182() {
40268
public void test1182() {
(-)src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java (-109 / +297 lines)
Lines 11-18 Link Here
11
package org.eclipse.jdt.core.tests.compiler.regression;
11
package org.eclipse.jdt.core.tests.compiler.regression;
12
12
13
import junit.framework.*;
13
import junit.framework.*;
14
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
15
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
16
14
17
public class AmbiguousMethodTest extends AbstractComparableTest {
15
public class AmbiguousMethodTest extends AbstractComparableTest {
18
16
Lines 231-237 Link Here
231
	}
229
	}
232
	public void test005() {
230
	public void test005() {
233
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
231
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
234
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return;
235
		this.runNegativeTest(
232
		this.runNegativeTest(
236
			new String[] {
233
			new String[] {
237
				"X.java",
234
				"X.java",
Lines 245-261 Link Here
245
				"class A {}\n" +
242
				"class A {}\n" +
246
				"class B {}\n"
243
				"class B {}\n"
247
			},
244
			},
248
			"----------\n" +
245
			"----------\n" + 
249
			"1. ERROR in X.java (at line 5)\n" +
246
			"1. ERROR in X.java (at line 2)\n" + 
250
			"	new X().foo();\n" +
247
			"	<S extends A> void foo() { }\n" + 
251
			"	        ^^^\n" +
248
			"	                   ^^^^^\n" + 
252
			"The method foo() is ambiguous for the type X\n" +
249
			"Duplicate method foo() in type X\n" + 
250
			"----------\n" + 
251
			"2. ERROR in X.java (at line 3)\n" + 
252
			"	<N extends B> N foo() { return null; }\n" + 
253
			"	                ^^^^^\n" + 
254
			"Duplicate method foo() in type X\n" + 
253
			"----------\n"
255
			"----------\n"
254
		);
256
		);
257
/* javac 7
258
X.java:3: name clash: <N>foo() and <S>foo() have the same erasure
259
                 <N extends B> N foo() { return null; }
260
                                 ^
261
  where N,S are type-variables:
262
    N extends B declared in method <N>foo()
263
    S extends A declared in method <S>foo()
264
1 error
265
 */
255
	}
266
	}
256
	public void test006() {
267
	public void test006() {
257
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
268
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
258
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return;
259
		this.runNegativeTest(
269
		this.runNegativeTest(
260
			new String[] {
270
			new String[] {
261
				"X.java",
271
				"X.java",
Lines 273-289 Link Here
273
				"}\n"
283
				"}\n"
274
			},
284
			},
275
			"----------\n" +
285
			"----------\n" +
276
			"1. ERROR in X.java (at line 3)\n" +
286
			"1. ERROR in X.java (at line 3)\n" + 
277
			"	new Y<Object>().foo(\"X\");\n" +
287
			"	new Y<Object>().foo(\"X\");\n" + 
278
			"	                ^^^\n" +
288
			"	                ^^^\n" + 
279
			"The method foo(Object) is ambiguous for the type Y<Object>\n" +
289
			"The method foo(Object) is ambiguous for the type Y<Object>\n" + 
280
			"----------\n" +
290
			"----------\n" + 
281
			"2. ERROR in X.java (at line 4)\n" +
291
			"2. ERROR in X.java (at line 4)\n" + 
282
			"	new Y<Object>().foo2(\"X\");\n" +
292
			"	new Y<Object>().foo2(\"X\");\n" + 
283
			"	                ^^^^\n" +
293
			"	                ^^^^\n" + 
284
			"The method foo2(Object) is ambiguous for the type Y<Object>\n" +
294
			"The method foo2(Object) is ambiguous for the type Y<Object>\n" + 
295
			"----------\n" + 
296
			"3. ERROR in X.java (at line 10)\n" + 
297
			"	void foo(T2 t) {}\n" + 
298
			"	     ^^^^^^^^^\n" + 
299
			"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" + 
300
			"----------\n" + 
301
			"4. ERROR in X.java (at line 11)\n" + 
302
			"	<U3> void foo2(T2 t) {}\n" + 
303
			"	          ^^^^^^^^^^\n" + 
304
			"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" + 
285
			"----------\n"
305
			"----------\n"
286
		);
306
		);
307
/* javac 7
308
X.java:3: reference to foo is ambiguous, both method <U1>foo(U1) in X and method
309
 foo(T2) in Y match
310
        new Y<Object>().foo("X");
311
                       ^
312
  where U1,T2 are type-variables:
313
    U1 extends Object declared in method <U1>foo(U1)
314
    T2 extends Object declared in class Y
315
X.java:4: reference to foo2 is ambiguous, both method <U2>foo2(U2) in X and meth
316
od <U3>foo2(T2) in Y match
317
        new Y<Object>().foo2("X");
318
                       ^
319
  where U2,U3,T2 are type-variables:
320
    U2 extends Object declared in method <U2>foo2(U2)
321
    U3 extends Object declared in method <U3>foo2(T2)
322
    T2 extends Object declared in class Y
323
X.java:10: name clash: foo(T2) in Y and <U1>foo(U1) in X have the same erasure,
324
yet neither overrides the other
325
        void foo(T2 t) {}
326
             ^
327
  where T2,U1 are type-variables:
328
    T2 extends Object declared in class Y
329
    U1 extends Object declared in method <U1>foo(U1)
330
X.java:11: name clash: <U3>foo2(T2) in Y and <U2>foo2(U2) in X have the same era
331
sure, yet neither overrides the other
332
        <U3> void foo2(T2 t) {}
333
                  ^
334
  where U3,T2,U2 are type-variables:
335
    U3 extends Object declared in method <U3>foo2(T2)
336
    T2 extends Object declared in class Y
337
    U2 extends Object declared in method <U2>foo2(U2)
338
4 errors
339
 */
287
	}
340
	}
288
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=129056
341
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=129056
289
	public void test007() {
342
	public void test007() {
Lines 396-413 Link Here
396
			"   }\n" +
449
			"   }\n" +
397
			"}"
450
			"}"
398
		},
451
		},
399
		"----------\n" +
452
		"----------\n" + 
400
		"1. ERROR in X.java (at line 4)\n" +
453
		"1. ERROR in X.java (at line 8)\n" + 
401
		"	static <L1 extends Listener & ErrorListener> Object createParser(L1 l) { return null; }\n" +
454
		"	createParser(new A());\n" + 
402
		"	                                                    ^^^^^^^^^^^^^^^^^^\n" +
455
		"	^^^^^^^^^^^^\n" + 
403
		"Method createParser(L1) has the same erasure createParser(X.Listener) as another method in type X\n" +
456
		"The method createParser(A) is ambiguous for the type X\n" + 
404
		"----------\n" +
405
		"2. ERROR in X.java (at line 5)\n" +
406
		"	static <L2 extends ErrorListener & Listener> Object createParser(L2 l) { return null; }\n" +
407
		"	                                                    ^^^^^^^^^^^^^^^^^^\n" +
408
		"Method createParser(L2) has the same erasure createParser(X.ErrorListener) as another method in type X\n" +
409
		"----------\n"
457
		"----------\n"
410
	);
458
	);
459
// javac 7 randomly picks which ever method is second
411
}
460
}
412
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=121024
461
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=121024
413
public void test010b() {
462
public void test010b() {
Lines 480-487 Link Here
480
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106090
529
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106090
481
	public void test011a() {
530
	public void test011a() {
482
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
531
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
483
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return;
532
		this.runNegativeTest(
484
		this.runConformTest(
485
			new String[] {
533
			new String[] {
486
				"Combined.java",
534
				"Combined.java",
487
				"public class Combined<A, B> {\n" +
535
				"public class Combined<A, B> {\n" +
Lines 495-507 Link Here
495
				"class ExOne extends Exception {static final long serialVersionUID = 1;}\n" +
543
				"class ExOne extends Exception {static final long serialVersionUID = 1;}\n" +
496
				"class ExTwo extends Exception {static final long serialVersionUID = 2;}"
544
				"class ExTwo extends Exception {static final long serialVersionUID = 2;}"
497
			},
545
			},
498
			""
546
			"----------\n" + 
547
			"1. ERROR in Combined.java (at line 2)\n" + 
548
			"	<T extends Comparable<T>> void pickOne(T value) throws ExOne {}\n" + 
549
			"	                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
550
			"Method pickOne(T) has the same erasure pickOne(Comparable<T>) as another method in type Combined<A,B>\n" + 
551
			"----------\n" + 
552
			"2. ERROR in Combined.java (at line 3)\n" + 
553
			"	<T> T pickOne(Comparable<T> value) throws ExTwo { return null;}\n" + 
554
			"	      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
555
			"Method pickOne(Comparable<T>) has the same erasure pickOne(Comparable<T>) as another method in type Combined<A,B>\n" + 
556
			"----------\n"
499
		);
557
		);
558
/* javac 7
559
X.java:3: name clash: <T#1>pickOne(Comparable<T#1>) and <T#2>pickOne(T#2) have the same erasure
560
        <T> T pickOne(Comparable<T> value) throws ExTwo { return null;}
561
              ^
562
  where T#1,T#2 are type-variables:
563
    T#1 extends Object declared in method <T#1>pickOne(Comparable<T#1>)
564
    T#2 extends Comparable<T#2> declared in method <T#2>pickOne(T#2)
565
1 error
566
 */
500
	}
567
	}
501
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106090
568
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106090
502
	public void test011b() {
569
	public void test011b() {
503
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
570
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
504
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return;
505
		this.runNegativeTest(
571
		this.runNegativeTest(
506
			new String[] {
572
			new String[] {
507
				"Test1.java",
573
				"Test1.java",
Lines 513-530 Link Here
513
				"class ExOne extends Exception {static final long serialVersionUID = 1;}\n" +
579
				"class ExOne extends Exception {static final long serialVersionUID = 1;}\n" +
514
				"class ExTwo extends Exception {static final long serialVersionUID = 2;}"
580
				"class ExTwo extends Exception {static final long serialVersionUID = 2;}"
515
			},
581
			},
516
			"----------\n" +
582
			"----------\n" + 
517
			"1. WARNING in Test1.java (at line 4)\n" +
583
			"1. ERROR in Test1.java (at line 2)\n" + 
518
			"	void pickOne2(Test1<Integer,Integer> c) throws ExOne { c.pickOne((Comparable) \"test\"); }\n" +
584
			"	<T extends Comparable<T>> void pickOne(T value) throws ExOne {}\n" + 
519
			"	                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
585
			"	                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
520
			"Type safety: Unchecked invocation pickOne(Comparable) of the generic method pickOne(T) of type Test1<Integer,Integer>\n" +
586
			"Method pickOne(T) has the same erasure pickOne(Comparable<T>) as another method in type Test1<AA,BB>\n" + 
521
			"----------\n" +
587
			"----------\n" + 
522
			"2. WARNING in Test1.java (at line 4)\n" +
588
			"2. ERROR in Test1.java (at line 3)\n" + 
523
			"	void pickOne2(Test1<Integer,Integer> c) throws ExOne { c.pickOne((Comparable) \"test\"); }\n" +
589
			"	<T> T pickOne(Comparable<T> value) throws ExTwo { return null;}\n" + 
524
			"	                                                                  ^^^^^^^^^^\n" +
590
			"	      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
525
			"Comparable is a raw type. References to generic type Comparable<T> should be parameterized\n" +
591
			"Method pickOne(Comparable<T>) has the same erasure pickOne(Comparable<T>) as another method in type Test1<AA,BB>\n" + 
592
			"----------\n" + 
593
			"3. WARNING in Test1.java (at line 4)\n" + 
594
			"	void pickOne2(Test1<Integer,Integer> c) throws ExOne { c.pickOne((Comparable) \"test\"); }\n" + 
595
			"	                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
596
			"Type safety: Unchecked invocation pickOne(Comparable) of the generic method pickOne(T) of type Test1<Integer,Integer>\n" + 
597
			"----------\n" + 
598
			"4. WARNING in Test1.java (at line 4)\n" + 
599
			"	void pickOne2(Test1<Integer,Integer> c) throws ExOne { c.pickOne((Comparable) \"test\"); }\n" + 
600
			"	                                                                  ^^^^^^^^^^\n" + 
601
			"Comparable is a raw type. References to generic type Comparable<T> should be parameterized\n" + 
526
			"----------\n"
602
			"----------\n"
527
		);
603
		);
604
/* javac 7
605
X.java:3: name clash: <T#1>pickOne(Comparable<T#1>) and <T#2>pickOne(T#2) have the same erasure
606
        <T> T pickOne(Comparable<T> value) throws ExTwo { return null;}
607
              ^
608
  where T#1,T#2 are type-variables:
609
    T#1 extends Object declared in method <T#1>pickOne(Comparable<T#1>)
610
    T#2 extends Comparable<T#2> declared in method <T#2>pickOne(T#2)
611
X.java:4: warning: [unchecked] unchecked method invocation: method pickOne in class Test1 is applied to given types
612
        void pickOne2(Test1<Integer,Integer> c) throws ExOne { c.pickOne((Comparable) "test"); }
613
                                                                        ^
614
  required: T
615
  found: Comparable
616
  where T is a type-variable:
617
    T extends Comparable<T> declared in method <T>pickOne(T)
618
1 error
619
1 warning
620
 */
528
	}
621
	}
529
	public void test012() {
622
	public void test012() {
530
		this.runConformTest(
623
		this.runConformTest(
Lines 1465-1472 Link Here
1465
	// variant: having both methods in the same class should not change anything
1558
	// variant: having both methods in the same class should not change anything
1466
	public void test021() {
1559
	public void test021() {
1467
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
1560
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
1468
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return;
1561
		this.runNegativeTest(
1469
		this.runConformTest(
1470
			new String[] {
1562
			new String[] {
1471
				"Y.java",
1563
				"Y.java",
1472
				"class X<T extends Object> {\n" +
1564
				"class X<T extends Object> {\n" +
Lines 1488-1564 Link Here
1488
				"  }\n" +
1580
				"  }\n" +
1489
				"}"
1581
				"}"
1490
			},
1582
			},
1491
			"true");
1583
			"----------\n" + 
1584
			"1. WARNING in Y.java (at line 3)\n" + 
1585
			"	public class Y<V extends String> extends X<V> {\n" + 
1586
			"	                         ^^^^^^\n" + 
1587
			"The type parameter V should not be bounded by the final type String. Final types cannot be further extended\n" + 
1588
			"----------\n" + 
1589
			"2. WARNING in Y.java (at line 4)\n" + 
1590
			"	public static <W extends String> Y<W> make(Class<W> clazz) {\n" + 
1591
			"	                         ^^^^^^\n" + 
1592
			"The type parameter W should not be bounded by the final type String. Final types cannot be further extended\n" + 
1593
			"----------\n" + 
1594
			"3. ERROR in Y.java (at line 4)\n" + 
1595
			"	public static <W extends String> Y<W> make(Class<W> clazz) {\n" + 
1596
			"	                                      ^^^^^^^^^^^^^^^^^^^^\n" + 
1597
			"Method make(Class<W>) has the same erasure make(Class<T>) as another method in type Y<V>\n" + 
1598
			"----------\n" + 
1599
			"4. ERROR in Y.java (at line 8)\n" + 
1600
			"	public static <U extends Object> X<U> make(Class<U> clazz) {\n" + 
1601
			"	                                      ^^^^^^^^^^^^^^^^^^^^\n" + 
1602
			"Method make(Class<U>) has the same erasure make(Class<T>) as another method in type Y<V>\n" + 
1603
			"----------\n" + 
1604
			"5. WARNING in Y.java (at line 13)\n" + 
1605
			"	Y.make(getClazz());\n" + 
1606
			"	^^^^^^^^^^^^^^^^^^\n" + 
1607
			"Type safety: Unchecked invocation make(Class) of the generic method make(Class<W>) of type Y\n" + 
1608
			"----------\n" + 
1609
			"6. WARNING in Y.java (at line 13)\n" + 
1610
			"	Y.make(getClazz());\n" + 
1611
			"	       ^^^^^^^^^^\n" + 
1612
			"Type safety: The expression of type Class needs unchecked conversion to conform to Class<String>\n" + 
1613
			"----------\n" + 
1614
			"7. WARNING in Y.java (at line 15)\n" + 
1615
			"	public static Class getClazz() {\n" + 
1616
			"	              ^^^^^\n" + 
1617
			"Class is a raw type. References to generic type Class<T> should be parameterized\n" + 
1618
			"----------\n"
1619
		);
1620
/* javac 7
1621
X.java:8: name clash: <U>make(Class<U>) and <W>make(Class<W>) have the same erasure
1622
  public static <U extends Object> X<U> make(Class<U> clazz) {
1623
                                        ^
1624
  where U,W are type-variables:
1625
    U extends Object declared in method <U>make(Class<U>)
1626
    W extends String declared in method <W>make(Class<W>)
1627
X.java:13: warning: [unchecked] unchecked conversion
1628
    Y.make(getClazz());
1629
                   ^
1630
  required: Class<W#1>
1631
  found:    Class
1632
  where W#1,W#2 are type-variables:
1633
    W#1 extends String declared in method <W#2>make(Class<W#2>)
1634
    W#2 extends String declared in method <W#2>make(Class<W#2>)
1635
X.java:13: warning: [unchecked] unchecked method invocation: method make in class Y is applied to given types
1636
    Y.make(getClazz());
1637
          ^
1638
  required: Class<W>
1639
  found: Class
1640
  where W is a type-variable:
1641
    W extends String declared in method <W>make(Class<W>)
1642
1 error
1643
2 warnings
1644
 */
1492
	}
1645
	}
1493
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=147647
1646
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=147647
1494
	// variant: using instances triggers raw methods, which are ambiguous
1647
	// variant: using instances triggers raw methods, which are ambiguous
1495
	public void test022() {
1648
	public void test022() {
1496
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
1649
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
1497
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return;
1498
		this.runNegativeTest(
1650
		this.runNegativeTest(
1499
		new String[] {
1651
			new String[] {
1500
			"X.java",
1652
				"X.java",
1501
			"public class X<T extends Object> {\n" +
1653
				"public class X<T extends Object> {\n" +
1502
			"}\n" +
1654
				"}\n" +
1503
			"class Y<V extends String> extends X<V> {\n" +
1655
				"class Y<V extends String> extends X<V> {\n" +
1504
			"  public <W extends String> Y<W> make(Class<W> clazz) {\n" +
1656
				"  public <W extends String> Y<W> make(Class<W> clazz) {\n" +
1505
			"    return new Y<W>();\n" +
1657
				"    return new Y<W>();\n" +
1506
			"  }\n" +
1658
				"  }\n" +
1507
			"  public <U extends Object> X<U> make(Class<U> clazz) {\n" +
1659
				"  public <U extends Object> X<U> make(Class<U> clazz) {\n" +
1508
			"    return new X<U>();\n" +
1660
				"    return new X<U>();\n" +
1509
			"  }\n" +
1661
				"  }\n" +
1510
			"  public static void main(String[] args) throws Exception {\n" +
1662
				"  public static void main(String[] args) throws Exception {\n" +
1511
			"    Y y = new Y();\n" +
1663
				"    Y y = new Y();\n" +
1512
			"    y.make(String.class);\n" +
1664
				"    y.make(String.class);\n" +
1513
			"    y.make(getClazz());\n" +
1665
				"    y.make(getClazz());\n" +
1514
			"    y.make(getClazz().newInstance().getClass());\n" +
1666
				"    y.make(getClazz().newInstance().getClass());\n" +
1515
			"  }\n" +
1667
				"  }\n" +
1516
			"  public static Class getClazz() {\n" +
1668
				"  public static Class getClazz() {\n" +
1517
			"    return String.class;\n" +
1669
				"    return String.class;\n" +
1518
			"  }\n" +
1670
				"  }\n" +
1519
			"}"
1671
				"}"
1520
		},
1672
			},
1521
		"----------\n" +
1673
			"----------\n" + 
1522
		"1. WARNING in X.java (at line 3)\n" +
1674
			"1. WARNING in X.java (at line 3)\n" + 
1523
		"	class Y<V extends String> extends X<V> {\n" +
1675
			"	class Y<V extends String> extends X<V> {\n" + 
1524
		"	                  ^^^^^^\n" +
1676
			"	                  ^^^^^^\n" + 
1525
		"The type parameter V should not be bounded by the final type String. Final types cannot be further extended\n" +
1677
			"The type parameter V should not be bounded by the final type String. Final types cannot be further extended\n" + 
1526
		"----------\n" +
1678
			"----------\n" + 
1527
		"2. WARNING in X.java (at line 4)\n" +
1679
			"2. WARNING in X.java (at line 4)\n" + 
1528
		"	public <W extends String> Y<W> make(Class<W> clazz) {\n" +
1680
			"	public <W extends String> Y<W> make(Class<W> clazz) {\n" + 
1529
		"	                  ^^^^^^\n" +
1681
			"	                  ^^^^^^\n" + 
1530
		"The type parameter W should not be bounded by the final type String. Final types cannot be further extended\n" +
1682
			"The type parameter W should not be bounded by the final type String. Final types cannot be further extended\n" + 
1531
		"----------\n" +
1683
			"----------\n" + 
1532
		"3. WARNING in X.java (at line 11)\n" +
1684
			"3. ERROR in X.java (at line 4)\n" + 
1533
		"	Y y = new Y();\n" +
1685
			"	public <W extends String> Y<W> make(Class<W> clazz) {\n" + 
1534
		"	^\n" +
1686
			"	                               ^^^^^^^^^^^^^^^^^^^^\n" + 
1535
		"Y is a raw type. References to generic type Y<V> should be parameterized\n" +
1687
			"Method make(Class<W>) has the same erasure make(Class<T>) as another method in type Y<V>\n" + 
1536
		"----------\n" +
1688
			"----------\n" + 
1537
		"4. WARNING in X.java (at line 11)\n" +
1689
			"4. ERROR in X.java (at line 7)\n" + 
1538
		"	Y y = new Y();\n" +
1690
			"	public <U extends Object> X<U> make(Class<U> clazz) {\n" + 
1539
		"	          ^\n" +
1691
			"	                               ^^^^^^^^^^^^^^^^^^^^\n" + 
1540
		"Y is a raw type. References to generic type Y<V> should be parameterized\n" +
1692
			"Method make(Class<U>) has the same erasure make(Class<T>) as another method in type Y<V>\n" + 
1541
		"----------\n" +
1693
			"----------\n" + 
1542
		"5. ERROR in X.java (at line 12)\n" +
1694
			"5. WARNING in X.java (at line 11)\n" + 
1543
		"	y.make(String.class);\n" +
1695
			"	Y y = new Y();\n" + 
1544
		"	  ^^^^\n" +
1696
			"	^\n" + 
1545
		"The method make(Class) is ambiguous for the type Y\n" +
1697
			"Y is a raw type. References to generic type Y<V> should be parameterized\n" + 
1546
		"----------\n" +
1698
			"----------\n" + 
1547
		"6. ERROR in X.java (at line 13)\n" +
1699
			"6. WARNING in X.java (at line 11)\n" + 
1548
		"	y.make(getClazz());\n" +
1700
			"	Y y = new Y();\n" + 
1549
		"	  ^^^^\n" +
1701
			"	          ^\n" + 
1550
		"The method make(Class) is ambiguous for the type Y\n" +
1702
			"Y is a raw type. References to generic type Y<V> should be parameterized\n" + 
1551
		"----------\n" +
1703
			"----------\n" + 
1552
		"7. ERROR in X.java (at line 14)\n" +
1704
			"7. WARNING in X.java (at line 12)\n" + 
1553
		"	y.make(getClazz().newInstance().getClass());\n" +
1705
			"	y.make(String.class);\n" + 
1554
		"	  ^^^^\n" +
1706
			"	^^^^^^^^^^^^^^^^^^^^\n" + 
1555
		"The method make(Class) is ambiguous for the type Y\n" +
1707
			"Type safety: The method make(Class) belongs to the raw type Y. References to generic type Y<V> should be parameterized\n" + 
1556
		"----------\n" +
1708
			"----------\n" + 
1557
		"8. WARNING in X.java (at line 16)\n" +
1709
			"8. WARNING in X.java (at line 13)\n" + 
1558
		"	public static Class getClazz() {\n" +
1710
			"	y.make(getClazz());\n" + 
1559
		"	              ^^^^^\n" +
1711
			"	^^^^^^^^^^^^^^^^^^\n" + 
1560
		"Class is a raw type. References to generic type Class<T> should be parameterized\n" +
1712
			"Type safety: The method make(Class) belongs to the raw type Y. References to generic type Y<V> should be parameterized\n" + 
1561
		"----------\n");
1713
			"----------\n" + 
1714
			"9. WARNING in X.java (at line 14)\n" + 
1715
			"	y.make(getClazz().newInstance().getClass());\n" + 
1716
			"	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
1717
			"Type safety: The method make(Class) belongs to the raw type Y. References to generic type Y<V> should be parameterized\n" + 
1718
			"----------\n" + 
1719
			"10. WARNING in X.java (at line 16)\n" + 
1720
			"	public static Class getClazz() {\n" + 
1721
			"	              ^^^^^\n" + 
1722
			"Class is a raw type. References to generic type Class<T> should be parameterized\n" + 
1723
			"----------\n"
1724
		);
1725
/* javac 7
1726
X.java:7: name clash: <U>make(Class<U>) and <W>make(Class<W>) have the same erasure
1727
  public <U extends Object> X<U> make(Class<U> clazz) {
1728
                                 ^
1729
  where U,W are type-variables:
1730
    U extends Object declared in method <U>make(Class<U>)
1731
    W extends String declared in method <W>make(Class<W>)
1732
X.java:12: warning: [unchecked] unchecked call to <W>make(Class<W>) as a member of the raw type Y
1733
    y.make(String.class);
1734
          ^
1735
  where W is a type-variable:
1736
    W extends String declared in method <W>make(Class<W>)
1737
X.java:13: warning: [unchecked] unchecked call to <W>make(Class<W>) as a member of the raw type Y
1738
    y.make(getClazz());
1739
          ^
1740
  where W is a type-variable:
1741
    W extends String declared in method <W>make(Class<W>)
1742
X.java:14: warning: [unchecked] unchecked call to <W>make(Class<W>) as a member of the raw type Y
1743
    y.make(getClazz().newInstance().getClass());
1744
          ^
1745
  where W is a type-variable:
1746
    W extends String declared in method <W>make(Class<W>)
1747
1 error
1748
3 warnings
1749
 */
1562
	}
1750
	}
1563
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=159711
1751
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=159711
1564
public void test023() {
1752
public void test023() {

Return to bug 289247