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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java (-3 / +11 lines)
Lines 2842-2854 Link Here
2842
		int oneParamsLength = oneParams.length;
2842
		int oneParamsLength = oneParams.length;
2843
		int twoParamsLength = twoParams.length;
2843
		int twoParamsLength = twoParams.length;
2844
		if (oneParamsLength == twoParamsLength) {
2844
		if (oneParamsLength == twoParamsLength) {
2845
			/* Below 1.5, discard any generics we have left in for the method verifier's benefit, (so it
2846
			   can detect method overriding properly in the presence of generic super types.) This is so
2847
			   as to allow us to determine whether we have been handed an acceptable method in 1.4 terms
2848
			   without all the 1.5ism below kicking in and spoiling the party.
2849
			   See https://bugs.eclipse.org/bugs/show_bug.cgi?id=331446
2850
			*/
2851
			boolean applyErasure =  environment().globalOptions.sourceLevel < ClassFileConstants.JDK1_5;
2845
			next : for (int i = 0; i < oneParamsLength; i++) {
2852
			next : for (int i = 0; i < oneParamsLength; i++) {
2846
				TypeBinding oneParam = oneParams[i];
2853
				TypeBinding oneParam = applyErasure ? oneParams[i].erasure() : oneParams[i];
2847
				TypeBinding twoParam = twoParams[i];
2854
				TypeBinding twoParam = applyErasure ? twoParams[i].erasure() : twoParams[i];
2848
				if (oneParam == twoParam || oneParam.isCompatibleWith(twoParam)) {
2855
				if (oneParam == twoParam || oneParam.isCompatibleWith(twoParam)) {
2849
					if (two.declaringClass.isRawType()) continue next;
2856
					if (two.declaringClass.isRawType()) continue next;
2850
2857
2851
					TypeBinding originalTwoParam = two.original().parameters[i].leafComponentType();
2858
					TypeBinding leafComponentType = two.original().parameters[i].leafComponentType();
2859
					TypeBinding originalTwoParam = applyErasure ? leafComponentType.erasure() : leafComponentType; 
2852
					switch (originalTwoParam.kind()) {
2860
					switch (originalTwoParam.kind()) {
2853
					   	case Binding.TYPE_PARAMETER :
2861
					   	case Binding.TYPE_PARAMETER :
2854
					   		if (((TypeVariableBinding) originalTwoParam).hasOnlyRawBounds())
2862
					   		if (((TypeVariableBinding) originalTwoParam).hasOnlyRawBounds())
(-)src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java (-68 / +137 lines)
Lines 11533-11540 Link Here
11533
		false,
11533
		false,
11534
		compilerOptions14);
11534
		compilerOptions14);
11535
}
11535
}
11536
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=331446 
11536
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=331446
11537
public void _test331446() {
11537
public void test331446() {
11538
	Map compilerOptions15 = getCompilerOptions();
11538
	Map compilerOptions15 = getCompilerOptions();
11539
	compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_5);
11539
	compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_5);
11540
	compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
11540
	compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
Lines 11573-11581 Link Here
11573
		null);
11573
		null);
11574
11574
11575
	Map compilerOptions14 = getCompilerOptions();
11575
	Map compilerOptions14 = getCompilerOptions();
11576
//	compilerOptions14.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5);
11577
//	compilerOptions14.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
11578
//	compilerOptions14.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5);
11579
	compilerOptions14.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2);
11576
	compilerOptions14.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2);
11580
	compilerOptions14.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4);
11577
	compilerOptions14.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4);
11581
	compilerOptions14.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3);
11578
	compilerOptions14.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3);
Lines 11606-11625 Link Here
11606
		compilerOptions14,
11603
		compilerOptions14,
11607
		null);
11604
		null);
11608
}
11605
}
11609
public void test1415Mix() {
11606
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=331446
11607
public void test331446a() {
11610
	Map compilerOptions15 = getCompilerOptions();
11608
	Map compilerOptions15 = getCompilerOptions();
11611
	compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_5);
11609
	compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_4);
11612
	compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
11610
	compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4);
11613
	compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5);
11611
	compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_4);
11614
	this.runConformTest(
11612
	this.runConformTest(
11615
		new String[] {
11613
		new String[] {
11616
			"Abstract.java",
11614
			"Test.java",
11617
			"abstract class Generic<T> {\n" +
11615
			"import java.util.Comparator;\n" + 
11618
			"	abstract void foo(T t);\n" +
11616
			"import java.util.List;\n" + 
11619
			"}\n" +
11617
			"\n" + 
11620
			"public abstract class Abstract extends Generic<String> {\n" +
11618
			"public class Test {\n" + 
11621
			"}"
11619
			"	public static  void assertEquals(String message,\n" + 
11622
			},
11620
			"			Comparator comparator, List expected, List actual) {\n" + 
11621
			"		if (expected.size() != actual.size()) {\n" + 
11622
			"			//failNotEquals(message, expected, actual);\n" + 
11623
			"		}\n" + 
11624
			"		for (int i = 0, l = expected.size(); i < l; i++) {\n" + 
11625
			"			assertEquals(message, comparator, expected.get(i), actual.get(i));\n" + 
11626
			"		}\n" + 
11627
			"	}\n" + 
11628
			"	public static void assertEquals(String message,\n" + 
11629
			"			Comparator comparator, Object expected, Object actual) {\n" + 
11630
			"		if (comparator.compare(expected, actual) == 0) {\n" + 
11631
			"			return;\n" + 
11632
			"		}\n" + 
11633
			"		//failNotEquals(message, expected, actual);\n" + 
11634
			"	}\n" + 
11635
			"}\n" + 
11636
			""
11637
		},
11623
		"",
11638
		"",
11624
		null,
11639
		null,
11625
		true,
11640
		true,
Lines 11632-11695 Link Here
11632
	compilerOptions14.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4);
11647
	compilerOptions14.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4);
11633
	compilerOptions14.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3);
11648
	compilerOptions14.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3);
11634
	compilerOptions14.put(JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK, JavaCore.IGNORE);
11649
	compilerOptions14.put(JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK, JavaCore.IGNORE);
11635
	this.runNegativeTest(
11636
		new String[] {
11637
			"Concrete.java",
11638
			"public class Concrete extends Abstract {\n" +
11639
			"}",
11640
		},
11641
		"----------\n" + 
11642
		"1. ERROR in Concrete.java (at line 1)\n" + 
11643
		"	public class Concrete extends Abstract {\n" + 
11644
		"	             ^^^^^^^^\n" + 
11645
		"The type Concrete must implement the inherited abstract method Generic<String>.foo(String)\n" + 
11646
		"----------\n",
11647
		null,
11648
		false,
11649
		compilerOptions14);	
11650
}
11651
public void test1415Mix2() {
11652
	Map compilerOptions15 = getCompilerOptions();
11653
	compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_5);
11654
	compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
11655
	compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5);
11656
	this.runConformTest(
11650
	this.runConformTest(
11657
		new String[] {
11651
		new String[] {
11658
			"Abstract.java",
11652
			"X.java",
11659
			"abstract class Generic<T> {\n" +
11653
			"import java.util.ArrayList;\n" + 
11660
			"	abstract void foo(T t);\n" +
11654
			"import java.util.Comparator;\n" + 
11661
			"}\n" +
11655
			"\n" + 
11662
			"public abstract class Abstract extends Generic<String> {\n" +
11656
			"public class X {\n" + 
11663
			"}"
11657
			"	public static void testAmbiguity() {\n" + 
11664
			},
11658
			"		Comparator comparator = new Comparator() {\n" + 
11659
			"			\n" + 
11660
			"			public int compare(Object o1, Object o2) {\n" + 
11661
			"				return 0;\n" + 
11662
			"			}\n" + 
11663
			"		};\n" + 
11664
			"		Test.assertEquals(\"Test\", comparator, new ArrayList(), new ArrayList());\n" + 
11665
			"	}\n" + 
11666
			"}\n" + 
11667
			"",
11668
		},
11665
		"",
11669
		"",
11666
		null,
11670
		null,
11667
		true,
11671
		false,
11668
		null,
11672
		null,
11669
		compilerOptions15,
11673
		compilerOptions14,
11670
		null);
11674
		null);
11671
11672
	Map compilerOptions14 = getCompilerOptions();
11673
	compilerOptions14.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2);
11674
	compilerOptions14.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4);
11675
	compilerOptions14.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3);
11676
	compilerOptions14.put(JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK, JavaCore.IGNORE);
11677
	this.runConformTest(
11678
			new String[] {
11679
					"Concrete.java",
11680
					"public class Concrete extends Abstract {\n" +
11681
					"    void foo(String s) {}\n" +
11682
					"}",
11683
			},
11684
			"",
11685
			null,
11686
			false,
11687
			null,
11688
			compilerOptions14,
11689
			null);	
11690
}
11675
}
11691
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=331446 (all 1.4)
11676
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=331446 (all 1.4)
11692
public void test331446a() {
11677
public void test331446b() {
11693
	Map compilerOptions14 = getCompilerOptions();
11678
	Map compilerOptions14 = getCompilerOptions();
11694
	compilerOptions14.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_4);
11679
	compilerOptions14.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_4);
11695
	compilerOptions14.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4);
11680
	compilerOptions14.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4);
Lines 11727-11733 Link Here
11727
		null);
11712
		null);
11728
}
11713
}
11729
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=331446 (1.4/1.5 mix)
11714
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=331446 (1.4/1.5 mix)
11730
public void _test331446b() {
11715
public void test331446c() {
11731
	Map compilerOptions15 = getCompilerOptions();
11716
	Map compilerOptions15 = getCompilerOptions();
11732
	compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_5);
11717
	compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_5);
11733
	compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
11718
	compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
Lines 11770-11776 Link Here
11770
		null);
11755
		null);
11771
}
11756
}
11772
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=331446 (all 1.5)
11757
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=331446 (all 1.5)
11773
public void test331446c() {
11758
public void test331446d() {
11774
	Map compilerOptions15 = getCompilerOptions();
11759
	Map compilerOptions15 = getCompilerOptions();
11775
	compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_5);
11760
	compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_5);
11776
	compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
11761
	compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
Lines 11806-11809 Link Here
11806
		compilerOptions15,
11791
		compilerOptions15,
11807
		null);
11792
		null);
11808
}
11793
}
11794
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=331446
11795
public void test1415Mix() {
11796
	Map compilerOptions15 = getCompilerOptions();
11797
	compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_5);
11798
	compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
11799
	compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5);
11800
	this.runConformTest(
11801
		new String[] {
11802
			"Abstract.java",
11803
			"abstract class Generic<T> {\n" +
11804
			"	abstract void foo(T t);\n" +
11805
			"}\n" +
11806
			"public abstract class Abstract extends Generic<String> {\n" +
11807
			"}"
11808
			},
11809
		"",
11810
		null,
11811
		true,
11812
		null,
11813
		compilerOptions15,
11814
		null);
11815
11816
	Map compilerOptions14 = getCompilerOptions();
11817
	compilerOptions14.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2);
11818
	compilerOptions14.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4);
11819
	compilerOptions14.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3);
11820
	compilerOptions14.put(JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK, JavaCore.IGNORE);
11821
	this.runNegativeTest(
11822
		new String[] {
11823
			"Concrete.java",
11824
			"public class Concrete extends Abstract {\n" +
11825
			"}",
11826
		},
11827
		"----------\n" + 
11828
		"1. ERROR in Concrete.java (at line 1)\n" + 
11829
		"	public class Concrete extends Abstract {\n" + 
11830
		"	             ^^^^^^^^\n" + 
11831
		"The type Concrete must implement the inherited abstract method Generic<String>.foo(String)\n" + 
11832
		"----------\n",
11833
		null,
11834
		false,
11835
		compilerOptions14);	
11836
}
11837
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=331446
11838
public void test1415Mix2() {
11839
	Map compilerOptions15 = getCompilerOptions();
11840
	compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_5);
11841
	compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
11842
	compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5);
11843
	this.runConformTest(
11844
		new String[] {
11845
			"Abstract.java",
11846
			"abstract class Generic<T> {\n" +
11847
			"	abstract void foo(T t);\n" +
11848
			"}\n" +
11849
			"public abstract class Abstract extends Generic<String> {\n" +
11850
			"}"
11851
			},
11852
		"",
11853
		null,
11854
		true,
11855
		null,
11856
		compilerOptions15,
11857
		null);
11858
11859
	Map compilerOptions14 = getCompilerOptions();
11860
	compilerOptions14.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2);
11861
	compilerOptions14.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4);
11862
	compilerOptions14.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3);
11863
	compilerOptions14.put(JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK, JavaCore.IGNORE);
11864
	this.runConformTest(
11865
		new String[] {
11866
				"Concrete.java",
11867
				"public class Concrete extends Abstract {\n" +
11868
				"    void foo(String s) {}\n" +
11869
				"}",
11870
		},
11871
		"",
11872
		null,
11873
		false,
11874
		null,
11875
		compilerOptions14,
11876
		null);
11877
}
11809
}
11878
}
(-)src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java (-1 / +1 lines)
Lines 5227-5233 Link Here
5227
			deleteProject(project14);
5227
			deleteProject(project14);
5228
	}
5228
	}
5229
}
5229
}
5230
public void _testGenericAPIUsageFromA14Project9() throws CoreException {
5230
public void testGenericAPIUsageFromA14Project9() throws CoreException {
5231
	IJavaProject project14 = null;
5231
	IJavaProject project14 = null;
5232
	IJavaProject project15 = null;
5232
	IJavaProject project15 = null;
5233
	try {
5233
	try {

Return to bug 331446