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

(-)compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java (-1 / +6 lines)
Lines 1096-1101 Link Here
1096
1096
1097
		// find & report collision cases
1097
		// find & report collision cases
1098
		boolean complyTo15 = this.scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5;
1098
		boolean complyTo15 = this.scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5;
1099
		boolean complyTo17 = this.scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_7;
1099
		for (int i = 0, length = this.methods.length; i < length; i++) {
1100
		for (int i = 0, length = this.methods.length; i < length; i++) {
1100
			MethodBinding method = resolvedMethods[i];
1101
			MethodBinding method = resolvedMethods[i];
1101
			if (method == null)
1102
			if (method == null)
Lines 1133-1140 Link Here
1133
					boolean equalParams = method.areParametersEqual(subMethod);
1134
					boolean equalParams = method.areParametersEqual(subMethod);
1134
					if (equalParams && equalTypeVars) {
1135
					if (equalParams && equalTypeVars) {
1135
						// duplicates regardless of return types
1136
						// duplicates regardless of return types
1136
					} else if (method.returnType.erasure() == subMethod.returnType.erasure() && (equalParams || method.areParameterErasuresEqual(method2))) {
1137
					} else if ((complyTo17 || method.returnType.erasure() == subMethod.returnType.erasure())
1138
						&& (equalParams || method.areParameterErasuresEqual(method2))) {
1139
						// with fix for http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
1140
						// we now ignore return types when detecting duplicates, just as we did before 1.5 
1137
						// name clash for sure if not duplicates, report as duplicates
1141
						// name clash for sure if not duplicates, report as duplicates
1142
						// FYI for now we will only make this change when compliance is set to 1.7 or higher
1138
					} else if (!equalTypeVars && vars != Binding.NO_TYPE_VARIABLES && vars2 != Binding.NO_TYPE_VARIABLES) {
1143
					} else if (!equalTypeVars && vars != Binding.NO_TYPE_VARIABLES && vars2 != Binding.NO_TYPE_VARIABLES) {
1139
						// type variables are different so we can distinguish between methods
1144
						// type variables are different so we can distinguish between methods
1140
						continue nextSibling;
1145
						continue nextSibling;
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java (-2 / +17 lines)
Lines 11-16 Link Here
11
package org.eclipse.jdt.internal.compiler.lookup;
11
package org.eclipse.jdt.internal.compiler.lookup;
12
12
13
import org.eclipse.jdt.internal.compiler.ast.TypeParameter;
13
import org.eclipse.jdt.internal.compiler.ast.TypeParameter;
14
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
14
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
15
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
15
import org.eclipse.jdt.internal.compiler.util.SimpleSet;
16
import org.eclipse.jdt.internal.compiler.util.SimpleSet;
16
17
Lines 546-553 Link Here
546
   return substitute;
547
   return substitute;
547
}
548
}
548
boolean detectInheritedNameClash(MethodBinding inherited, MethodBinding otherInherited) {
549
boolean detectInheritedNameClash(MethodBinding inherited, MethodBinding otherInherited) {
549
	if (!inherited.areParameterErasuresEqual(otherInherited) || inherited.returnType.erasure() != otherInherited.returnType.erasure())
550
	if (!inherited.areParameterErasuresEqual(otherInherited))
550
		return false;
551
		return false;
552
	if (this.environment.globalOptions.sourceLevel < ClassFileConstants.JDK1_7) {
553
		// with fix for http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
554
		// we now ignore return types when detecting name clashes
555
		// FYI for now we will only make this change when compliance is set to 1.7 or higher
556
		if (inherited.returnType.erasure() != otherInherited.returnType.erasure())
557
			return false;
558
	}
551
	// skip it if otherInherited is defined by a subtype of inherited's declaringClass
559
	// skip it if otherInherited is defined by a subtype of inherited's declaringClass
552
	if (inherited.declaringClass.erasure() != otherInherited.declaringClass.erasure())
560
	if (inherited.declaringClass.erasure() != otherInherited.declaringClass.erasure())
553
		if (inherited.declaringClass.findSuperTypeOriginatingFrom(otherInherited.declaringClass) != null)
561
		if (inherited.declaringClass.findSuperTypeOriginatingFrom(otherInherited.declaringClass) != null)
Lines 558-565 Link Here
558
}
566
}
559
boolean detectNameClash(MethodBinding current, MethodBinding inherited) {
567
boolean detectNameClash(MethodBinding current, MethodBinding inherited) {
560
	MethodBinding original = inherited.original(); // can be the same as inherited
568
	MethodBinding original = inherited.original(); // can be the same as inherited
561
	if (!current.areParameterErasuresEqual(original) || current.returnType.erasure() != original.returnType.erasure())
569
	if (!current.areParameterErasuresEqual(original))
562
		return false;
570
		return false;
571
	if (this.environment.globalOptions.sourceLevel < ClassFileConstants.JDK1_7) {
572
		// with fix for http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
573
		// we now ignore return types when detecting name clashes
574
		// FYI for now we will only make this change when compliance is set to 1.7 or higher
575
		if (current.returnType.erasure() != original.returnType.erasure())
576
			return false;
577
	}
563
578
564
	problemReporter(current).methodNameClash(current, inherited.declaringClass.isRawType() ? inherited : original);
579
	problemReporter(current).methodNameClash(current, inherited.declaringClass.isRawType() ? inherited : original);
565
	return true;
580
	return true;
(-)src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java (-1 / +114 lines)
Lines 3223-3228 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.runConformTest(
3227
		this.runConformTest(
3227
			new String[] {
3228
			new String[] {
3228
				"X1.java",
3229
				"X1.java",
Lines 3236-3241 Link Here
3236
	}
3237
	}
3237
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3238
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3238
	public void test048a() {
3239
	public void test048a() {
3240
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3239
		this.runConformTest(
3241
		this.runConformTest(
3240
			new String[] {
3242
			new String[] {
3241
				"X2.java",
3243
				"X2.java",
Lines 3278-3283 Link Here
3278
	}
3280
	}
3279
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3281
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3280
	public void test048c() {
3282
	public void test048c() {
3283
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3281
		this.runConformTest(
3284
		this.runConformTest(
3282
			new String[] {
3285
			new String[] {
3283
				"X4.java",
3286
				"X4.java",
Lines 3296-3301 Link Here
3296
	}
3299
	}
3297
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3300
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3298
	public void test048d() {
3301
	public void test048d() {
3302
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3299
		this.runConformTest(
3303
		this.runConformTest(
3300
			new String[] {
3304
			new String[] {
3301
				"X5.java",
3305
				"X5.java",
Lines 3314-3319 Link Here
3314
	}
3318
	}
3315
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3319
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3316
	public void test048e() {
3320
	public void test048e() {
3321
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3317
		this.runConformTest(
3322
		this.runConformTest(
3318
			new String[] {
3323
			new String[] {
3319
				"X6.java",
3324
				"X6.java",
Lines 3332-3337 Link Here
3332
	}
3337
	}
3333
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3338
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=85900
3334
	public void test048f() {
3339
	public void test048f() {
3340
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3335
		this.runConformTest(
3341
		this.runConformTest(
3336
			new String[] {
3342
			new String[] {
3337
				"X7.java",
3343
				"X7.java",
Lines 3433-3438 Link Here
3433
3439
3434
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=94754
3440
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=94754
3435
	public void test050() {
3441
	public void test050() {
3442
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3436
		this.runConformTest(
3443
		this.runConformTest(
3437
			new String[] {
3444
			new String[] {
3438
				"X.java",
3445
				"X.java",
Lines 3453-3458 Link Here
3453
	}
3460
	}
3454
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=94754
3461
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=94754
3455
	public void test050a() {
3462
	public void test050a() {
3463
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3456
		this.runNegativeTest(
3464
		this.runNegativeTest(
3457
			new String[] {
3465
			new String[] {
3458
				"X.java",
3466
				"X.java",
Lines 3484-3489 Link Here
3484
3492
3485
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation
3493
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation
3486
	public void test050b() {
3494
	public void test050b() {
3495
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3487
		this.runNegativeTest(
3496
		this.runNegativeTest(
3488
			new String[] {
3497
			new String[] {
3489
				"X.java",
3498
				"X.java",
Lines 3547-3552 Link Here
3547
	}
3556
	}
3548
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation
3557
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation
3549
	public void test050c() {
3558
	public void test050c() {
3559
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3550
		this.runNegativeTest(
3560
		this.runNegativeTest(
3551
			new String[] {
3561
			new String[] {
3552
				"X.java",
3562
				"X.java",
Lines 3580-3585 Link Here
3580
	}
3590
	}
3581
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation
3591
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation
3582
	public void test050d() {
3592
	public void test050d() {
3593
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3583
		this.runConformTest(
3594
		this.runConformTest(
3584
			new String[] {
3595
			new String[] {
3585
				"X.java",
3596
				"X.java",
Lines 3599-3604 Link Here
3599
3610
3600
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423
3611
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423
3601
	public void test050e() {
3612
	public void test050e() {
3613
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3602
		this.runConformTest(
3614
		this.runConformTest(
3603
			new String[] {
3615
			new String[] {
3604
				"X.java",
3616
				"X.java",
Lines 3697-3702 Link Here
3697
3709
3698
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423
3710
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423
3699
	public void test050i() {
3711
	public void test050i() {
3712
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3700
		this.runConformTest(
3713
		this.runConformTest(
3701
			new String[] {
3714
			new String[] {
3702
				"X.java",
3715
				"X.java",
Lines 3878-3883 Link Here
3878
	}
3891
	}
3879
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=89470
3892
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=89470
3880
	public void test051b() {
3893
	public void test051b() {
3894
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
3881
		this.runConformTest(
3895
		this.runConformTest(
3882
			new String[] {
3896
			new String[] {
3883
				"X.java",
3897
				"X.java",
Lines 4028-4033 Link Here
4028
	}
4042
	}
4029
	// more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897
4043
	// more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897
4030
	public void test054a() {
4044
	public void test054a() {
4045
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
4031
		this.runNegativeTest(
4046
		this.runNegativeTest(
4032
			new String[] {
4047
			new String[] {
4033
				"X.java",
4048
				"X.java",
Lines 4059-4064 Link Here
4059
	}
4074
	}
4060
	// more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897
4075
	// more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897
4061
	public void test054b() {
4076
	public void test054b() {
4077
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
4062
		this.runConformTest(
4078
		this.runConformTest(
4063
			new String[] {
4079
			new String[] {
4064
				"X.java",
4080
				"X.java",
Lines 4096-4101 Link Here
4096
	}
4112
	}
4097
	// more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897
4113
	// more duplicate tests, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=94897
4098
	public void test054d() {
4114
	public void test054d() {
4115
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
4099
		this.runConformTest(
4116
		this.runConformTest(
4100
			new String[] {
4117
			new String[] {
4101
				"X.java",
4118
				"X.java",
Lines 4216-4221 Link Here
4216
	}
4233
	}
4217
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=94898
4234
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=94898
4218
	public void test058a() {
4235
	public void test058a() {
4236
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
4219
		this.runNegativeTest(
4237
		this.runNegativeTest(
4220
			new String[] {
4238
			new String[] {
4221
				"X.java",
4239
				"X.java",
Lines 4246-4251 Link Here
4246
	}
4264
	}
4247
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=94898
4265
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=94898
4248
	public void test058b() {
4266
	public void test058b() {
4267
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
4249
		this.runNegativeTest(
4268
		this.runNegativeTest(
4250
			new String[] {
4269
			new String[] {
4251
				"X.java",
4270
				"X.java",
Lines 6209-6214 Link Here
6209
6228
6210
// name conflict
6229
// name conflict
6211
public void test101() {
6230
public void test101() {
6231
	if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
6212
	this.runNegativeTest(
6232
	this.runNegativeTest(
6213
		new String[] {
6233
		new String[] {
6214
			"X.java",
6234
			"X.java",
Lines 7293-7298 Link Here
7293
}
7313
}
7294
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=202830
7314
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=202830
7295
public void test120a() {
7315
public void test120a() {
7316
	if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return; // see test187()
7296
	this.runConformTest(
7317
	this.runConformTest(
7297
		new String[] {
7318
		new String[] {
7298
			"Bar.java",
7319
			"Bar.java",
Lines 8992-8998 Link Here
8992
9013
8993
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=251091
9014
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=251091
8994
public void test177() {
9015
public void test177() {
8995
	if (new CompilerOptions(getCompilerOptions()).sourceLevel >= ClassFileConstants.JDK1_6) {
9016
	if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) { // see test187()
9017
		this.runNegativeTest(
9018
			new String[] {
9019
				"X.java",
9020
				"import java.util.*;\n" +
9021
				"interface I { I foo(Collection<?> c); }\n" +
9022
				"class A extends LinkedHashMap {\n" +
9023
				"	public A foo(Collection c) { return this; }\n" +
9024
				"}\n" +
9025
				"class X extends A implements I {\n" +
9026
				"	@Override public X foo(Collection<?> c) { return this; }\n" +
9027
				"}"
9028
			},
9029
			"----------\n" + 
9030
			"1. WARNING in X.java (at line 3)\n" + 
9031
			"	class A extends LinkedHashMap {\n" + 
9032
			"	      ^\n" + 
9033
			"The serializable class A does not declare a static final serialVersionUID field of type long\n" + 
9034
			"----------\n" + 
9035
			"2. WARNING in X.java (at line 3)\n" + 
9036
			"	class A extends LinkedHashMap {\n" + 
9037
			"	                ^^^^^^^^^^^^^\n" + 
9038
			"LinkedHashMap is a raw type. References to generic type LinkedHashMap<K,V> should be parameterized\n" + 
9039
			"----------\n" + 
9040
			"3. WARNING in X.java (at line 4)\n" + 
9041
			"	public A foo(Collection c) { return this; }\n" + 
9042
			"	             ^^^^^^^^^^\n" + 
9043
			"Collection is a raw type. References to generic type Collection<E> should be parameterized\n" + 
9044
			"----------\n" + 
9045
			"4. ERROR in X.java (at line 6)\n" + 
9046
			"	class X extends A implements I {\n" + 
9047
			"	      ^\n" + 
9048
			"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" + 
9049
			"----------\n" + 
9050
			"5. WARNING in X.java (at line 6)\n" + 
9051
			"	class X extends A implements I {\n" + 
9052
			"	      ^\n" + 
9053
			"The serializable class X does not declare a static final serialVersionUID field of type long\n" + 
9054
			"----------\n" + 
9055
			"6. ERROR in X.java (at line 7)\n" + 
9056
			"	@Override public X foo(Collection<?> c) { return this; }\n" + 
9057
			"	                   ^^^^^^^^^^^^^^^^^^^^\n" + 
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" + 
9059
			"----------\n"
9060
		);
9061
	} else if (new CompilerOptions(getCompilerOptions()).sourceLevel == ClassFileConstants.JDK1_6) {
8996
		this.runConformTest(
9062
		this.runConformTest(
8997
			new String[] {
9063
			new String[] {
8998
				"X.java",
9064
				"X.java",
Lines 9506-9509 Link Here
9506
		"----------\n"
9572
		"----------\n"
9507
	);
9573
	);
9508
}
9574
}
9575
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
9576
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=?
9577
public void test187() {
9578
	this.runNegativeTest(
9579
		new String[] {
9580
			"X.java",
9581
			"import java.util.*;\n" +
9582
			"class X {\n" +
9583
			"    int f(List<String> l) {return 0;}\n" +
9584
			"}\n" +
9585
			"class Y extends X {\n" +
9586
			"    double f(List<Integer> l) {return 0;}\n" +
9587
			"}\n" +
9588
			"interface I {\n" +
9589
			"	double f(List<Integer> l);\n" +
9590
			"}\n" +
9591
			"abstract class Z extends X implements I {}\n" +
9592
			"class XX {\n" +
9593
			"    int f(List<String> l) {return 0;}\n" +
9594
    			"double f(List<Integer> l) {return 0;}\n" +
9595
			"}"
9596
		},
9597
		new CompilerOptions(getCompilerOptions()).complianceLevel < ClassFileConstants.JDK1_7
9598
			? ""
9599
			: "----------\n" + 
9600
			"1. ERROR in X.java (at line 6)\n" + 
9601
			"	double f(List<Integer> l) {return 0;}\n" + 
9602
			"	       ^^^^^^^^^^^^^^^^^^\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" + 
9604
			"----------\n" + 
9605
			"2. ERROR in X.java (at line 11)\n" + 
9606
			"	abstract class Z extends X implements I {}\n" + 
9607
			"	               ^\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" + 
9609
			"----------\n" + 
9610
			"3. ERROR in X.java (at line 13)\n" + 
9611
			"	int f(List<String> l) {return 0;}\n" + 
9612
			"	    ^^^^^^^^^^^^^^^^^\n" + 
9613
			"Method f(List<String>) has the same erasure f(List<E>) as another method in type XX\n" + 
9614
			"----------\n" + 
9615
			"4. ERROR in X.java (at line 14)\n" + 
9616
			"	double f(List<Integer> l) {return 0;}\n" + 
9617
			"	       ^^^^^^^^^^^^^^^^^^\n" + 
9618
			"Method f(List<Integer>) has the same erasure f(List<E>) as another method in type XX\n" + 
9619
			"----------\n"
9620
	);
9621
}
9509
}
9622
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java (+17 lines)
Lines 17605-17610 Link Here
17605
17605
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
17609
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return;
17608
		this.runConformTest(
17610
		this.runConformTest(
17609
			new String[] {
17611
			new String[] {
17610
				"X.java",
17612
				"X.java",
Lines 17937-17942 Link Here
17937
	}
17939
	}
17938
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation
17940
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=90423 - variation
17939
	public void test0574() {
17941
	public void test0574() {
17942
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
17943
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return;
17940
		this.runNegativeTest(
17944
		this.runNegativeTest(
17941
			new String[] {
17945
			new String[] {
17942
				"X.java",
17946
				"X.java",
Lines 22371-22380 Link Here
22371
			"	bb.<Object>test();\r\n" +
22375
			"	bb.<Object>test();\r\n" +
22372
			"	           ^^^^\n" +
22376
			"	           ^^^^\n" +
22373
			"The method test() is ambiguous for the type BB\n" +
22377
			"The method test() is ambiguous for the type BB\n" +
22378
			"----------\n" + 
22379
			"2. ERROR in X.java (at line 9)\n" + 
22380
			"	class BB extends AA<CC> { <U> BB test() {return null;} }\n" + 
22381
			"	                                 ^^^^^^\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" + 
22374
			"----------\n");
22383
			"----------\n");
22375
}
22384
}
22376
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=97219
22385
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=97219
22377
public void test0706a() {
22386
public void test0706a() {
22387
	// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
22388
	if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return;
22378
	this.runNegativeTest(
22389
	this.runNegativeTest(
22379
		new String[] {
22390
		new String[] {
22380
			"X.java",
22391
			"X.java",
Lines 22411-22416 Link Here
22411
}
22422
}
22412
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=97219
22423
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=97219
22413
public void test0706b() {
22424
public void test0706b() {
22425
	// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
22426
	if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return;
22414
	this.runNegativeTest(
22427
	this.runNegativeTest(
22415
		new String[] {
22428
		new String[] {
22416
			"X.java",
22429
			"X.java",
Lines 23596-23601 Link Here
23596
}
23609
}
23597
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=100007
23610
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=100007
23598
public void test0748() {
23611
public void test0748() {
23612
	// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
23613
	if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return;
23599
	this.runNegativeTest(
23614
	this.runNegativeTest(
23600
		new String[] {
23615
		new String[] {
23601
			"X.java",
23616
			"X.java",
Lines 40008-40013 Link Here
40008
}
40023
}
40009
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=204534
40024
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=204534
40010
public void test1181() {
40025
public void test1181() {
40026
	// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
40027
	if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return;
40011
	this.runNegativeTest(
40028
	this.runNegativeTest(
40012
		new String[] {
40029
		new String[] {
40013
			"X.java",
40030
			"X.java",
(-)src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java (-82 / +96 lines)
Lines 11-16 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;
14
16
15
public class AmbiguousMethodTest extends AbstractComparableTest {
17
public class AmbiguousMethodTest extends AbstractComparableTest {
16
18
Lines 228-233 Link Here
228
		);
230
		);
229
	}
231
	}
230
	public void test005() {
232
	public void test005() {
233
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
234
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return;
231
		this.runNegativeTest(
235
		this.runNegativeTest(
232
			new String[] {
236
			new String[] {
233
				"X.java",
237
				"X.java",
Lines 250-255 Link Here
250
		);
254
		);
251
	}
255
	}
252
	public void test006() {
256
	public void test006() {
257
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
258
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return;
253
		this.runNegativeTest(
259
		this.runNegativeTest(
254
			new String[] {
260
			new String[] {
255
				"X.java",
261
				"X.java",
Lines 473-478 Link Here
473
	}
479
	}
474
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106090
480
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106090
475
	public void test011a() {
481
	public void test011a() {
482
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
483
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return;
476
		this.runConformTest(
484
		this.runConformTest(
477
			new String[] {
485
			new String[] {
478
				"Combined.java",
486
				"Combined.java",
Lines 492-497 Link Here
492
	}
500
	}
493
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106090
501
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106090
494
	public void test011b() {
502
	public void test011b() {
503
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
504
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return;
495
		this.runNegativeTest(
505
		this.runNegativeTest(
496
			new String[] {
506
			new String[] {
497
				"Test1.java",
507
				"Test1.java",
Lines 1454-1487 Link Here
1454
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=147647
1464
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=147647
1455
	// variant: having both methods in the same class should not change anything
1465
	// variant: having both methods in the same class should not change anything
1456
	public void test021() {
1466
	public void test021() {
1457
	this.runConformTest(
1467
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
1458
		new String[] {
1468
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return;
1459
			"Y.java",
1469
		this.runConformTest(
1460
			"class X<T extends Object> {\n" +
1470
			new String[] {
1461
			"}\n" +
1471
				"Y.java",
1462
			"public class Y<V extends String> extends X<V> {\n" +
1472
				"class X<T extends Object> {\n" +
1463
			"  public static <W extends String> Y<W> make(Class<W> clazz) {\n" +
1473
				"}\n" +
1464
			"    System.out.print(true);\n" +
1474
				"public class Y<V extends String> extends X<V> {\n" +
1465
			"    return new Y<W>();\n" +
1475
				"  public static <W extends String> Y<W> make(Class<W> clazz) {\n" +
1466
			"  }\n" +
1476
				"    System.out.print(true);\n" +
1467
			"  public static <U extends Object> X<U> make(Class<U> clazz) {\n" +
1477
				"    return new Y<W>();\n" +
1468
			"    System.out.print(false);\n" +
1478
				"  }\n" +
1469
			"    return new X<U>();\n" +
1479
				"  public static <U extends Object> X<U> make(Class<U> clazz) {\n" +
1470
			"  }\n" +
1480
				"    System.out.print(false);\n" +
1471
			"  public static void main(String[] args) throws Exception {\n" +
1481
				"    return new X<U>();\n" +
1472
			"    Y.make(getClazz());\n" +
1482
				"  }\n" +
1473
			"  }\n" +
1483
				"  public static void main(String[] args) throws Exception {\n" +
1474
			"  public static Class getClazz() {\n" +
1484
				"    Y.make(getClazz());\n" +
1475
			"    return String.class;\n" +
1485
				"  }\n" +
1476
			"  }\n" +
1486
				"  public static Class getClazz() {\n" +
1477
			"}"
1487
				"    return String.class;\n" +
1478
		},
1488
				"  }\n" +
1479
		"true");
1489
				"}"
1490
			},
1491
			"true");
1480
	}
1492
	}
1481
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=147647
1493
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=147647
1482
	// variant: using instances triggers raw methods, which are ambiguous
1494
	// variant: using instances triggers raw methods, which are ambiguous
1483
	public void test022() {
1495
	public void test022() {
1484
	this.runNegativeTest(
1496
		// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6182950
1497
		if (new CompilerOptions(getCompilerOptions()).complianceLevel >= ClassFileConstants.JDK1_7) return;
1498
		this.runNegativeTest(
1485
		new String[] {
1499
		new String[] {
1486
			"X.java",
1500
			"X.java",
1487
			"public class X<T extends Object> {\n" +
1501
			"public class X<T extends Object> {\n" +
Lines 1548-1615 Link Here
1548
	}
1562
	}
1549
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=159711
1563
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=159711
1550
public void test023() {
1564
public void test023() {
1551
this.runConformTest(
1565
	this.runConformTest(
1552
	new String[] {
1566
		new String[] {
1553
		"X.java",
1567
			"X.java",
1554
		"import java.util.*;\n" +
1568
			"import java.util.*;\n" +
1555
		"public class X {\n" +
1569
			"public class X {\n" +
1556
		"  public static void staticFoo(Collection<?> p) {\n" +
1570
			"  public static void staticFoo(Collection<?> p) {\n" +
1557
		"    System.out.print(1);\n" +
1571
			"    System.out.print(1);\n" +
1558
		"  }\n" +
1572
			"  }\n" +
1559
		"  public static <T extends List<?>> void staticFoo(T p) {\n" +
1573
			"  public static <T extends List<?>> void staticFoo(T p) {\n" +
1560
		"    System.out.print(2);\n" +
1574
			"    System.out.print(2);\n" +
1561
		"  }\n" +
1575
			"  }\n" +
1562
		"  public void foo(Collection<?> p) {\n" +
1576
			"  public void foo(Collection<?> p) {\n" +
1563
		"    System.out.print(1);\n" +
1577
			"    System.out.print(1);\n" +
1564
		"  }\n" +
1578
			"  }\n" +
1565
		"  public <T extends List<?>> void foo(T p) {\n" +
1579
			"  public <T extends List<?>> void foo(T p) {\n" +
1566
		"    System.out.print(2);\n" +
1580
			"    System.out.print(2);\n" +
1567
		"  }\n" +
1581
			"  }\n" +
1568
		"  public void foo2(Collection<?> p) {\n" +
1582
			"  public void foo2(Collection<?> p) {\n" +
1569
		"    System.out.print(1);\n" +
1583
			"    System.out.print(1);\n" +
1570
		"  }\n" +
1584
			"  }\n" +
1571
		"  public void foo2(List<?> p) {\n" +
1585
			"  public void foo2(List<?> p) {\n" +
1572
		"    System.out.print(2);\n" +
1586
			"    System.out.print(2);\n" +
1573
		"  }\n" +
1587
			"  }\n" +
1574
		"  public static void main(String[] args) {\n" +
1588
			"  public static void main(String[] args) {\n" +
1575
		"    staticFoo(new ArrayList<String>(Arrays.asList(\"\")));\n" +
1589
			"    staticFoo(new ArrayList<String>(Arrays.asList(\"\")));\n" +
1576
		"    new X().foo(new ArrayList<String>(Arrays.asList(\"\")));\n" +
1590
			"    new X().foo(new ArrayList<String>(Arrays.asList(\"\")));\n" +
1577
		"    new X().foo2(new ArrayList<String>(Arrays.asList(\"\")));\n" +
1591
			"    new X().foo2(new ArrayList<String>(Arrays.asList(\"\")));\n" +
1578
		"  }\n" +
1592
			"  }\n" +
1579
		"}"
1593
			"}"
1580
	},
1594
		},
1581
	"222");
1595
		"222");
1582
}
1596
}
1583
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=159711
1597
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=159711
1584
// self contained variant
1598
// self contained variant
1585
public void test024() {
1599
public void test024() {
1586
this.runConformTest(
1600
	this.runConformTest(
1587
	new String[] {
1601
		new String[] {
1588
		"X.java",
1602
			"X.java",
1589
		"public class X {\n" +
1603
			"public class X {\n" +
1590
		"  public static void foo(L1<?> p) {\n" +
1604
			"  public static void foo(L1<?> p) {\n" +
1591
		"    System.out.println(1);\n" +
1605
			"    System.out.println(1);\n" +
1592
		"  }\n" +
1606
			"  }\n" +
1593
		"  public static <T extends L2<?>> void foo(T p) {\n" +
1607
			"  public static <T extends L2<?>> void foo(T p) {\n" +
1594
		"    System.out.println(2);\n" +
1608
			"    System.out.println(2);\n" +
1595
		"  }\n" +
1609
			"  }\n" +
1596
		"  public static void main(String[] args) {\n" +
1610
			"  public static void main(String[] args) {\n" +
1597
		"    foo(new L3<String>());\n" +
1611
			"    foo(new L3<String>());\n" +
1598
		"  }\n" +
1612
			"  }\n" +
1599
		"}",
1613
			"}",
1600
		"L1.java",
1614
			"L1.java",
1601
		"public interface L1<T> {\n" +
1615
			"public interface L1<T> {\n" +
1602
		"}",
1616
			"}",
1603
		"L2.java",
1617
			"L2.java",
1604
		"public interface L2<T> extends L1<T> {\n" +
1618
			"public interface L2<T> extends L1<T> {\n" +
1605
		"}",
1619
			"}",
1606
		"L3.java",
1620
			"L3.java",
1607
		"public class L3<T> implements L2<T> {\n" +
1621
			"public class L3<T> implements L2<T> {\n" +
1608
		"  public L3() {\n" +
1622
			"  public L3() {\n" +
1609
		"  }\n" +
1623
			"  }\n" +
1610
		"}",
1624
			"}",
1611
	},
1625
		},
1612
	"2");
1626
		"2");
1613
}
1627
}
1614
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=162026
1628
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=162026
1615
public void test025() {
1629
public void test025() {

Return to bug 273862