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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java (-4 / +10 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 390-397 Link Here
390
									return false;
390
									return false;
391
							} else {
391
							} else {
392
								// pre1.5 semantics - no covariance allowed (even if 1.5 compliant, but 1.4 source)
392
								// pre1.5 semantics - no covariance allowed (even if 1.5 compliant, but 1.4 source)
393
								MethodBinding[] castTypeMethods = getAllInheritedMethods((ReferenceBinding) castType);
393
								// look at original methods rather than the parameterized variants at 1.4 to detect
394
								MethodBinding[] expressionTypeMethods = getAllInheritedMethods((ReferenceBinding) expressionType);
394
								// covariance. Otherwise when confronted with one raw type and one parameterized type,
395
								// we could mistakenly detect covariance and scream foul. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=332744
396
								MethodBinding[] castTypeMethods = getAllOriginalInheritedMethods((ReferenceBinding) castType);
397
								MethodBinding[] expressionTypeMethods = getAllOriginalInheritedMethods((ReferenceBinding) expressionType);
395
								int exprMethodsLength = expressionTypeMethods.length;
398
								int exprMethodsLength = expressionTypeMethods.length;
396
								for (int i = 0, castMethodsLength = castTypeMethods.length; i < castMethodsLength; i++) {
399
								for (int i = 0, castMethodsLength = castTypeMethods.length; i < castMethodsLength; i++) {
397
									for (int j = 0; j < exprMethodsLength; j++) {
400
									for (int j = 0; j < exprMethodsLength; j++) {
Lines 739-747 Link Here
739
	codeStream.invokeStringConcatenationStringConstructor();
742
	codeStream.invokeStringConcatenationStringConstructor();
740
}
743
}
741
744
742
private MethodBinding[] getAllInheritedMethods(ReferenceBinding binding) {
745
private MethodBinding[] getAllOriginalInheritedMethods(ReferenceBinding binding) {
743
	ArrayList collector = new ArrayList();
746
	ArrayList collector = new ArrayList();
744
	getAllInheritedMethods0(binding, collector);
747
	getAllInheritedMethods0(binding, collector);
748
	for (int i = 0, len = collector.size(); i < len; i++) {
749
		collector.set(i, ((MethodBinding)collector.get(i)).original());
750
	}
745
	return (MethodBinding[]) collector.toArray(new MethodBinding[collector.size()]);
751
	return (MethodBinding[]) collector.toArray(new MethodBinding[collector.size()]);
746
}
752
}
747
753
(-)src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java (-1 / +94 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11875-11878 Link Here
11875
		compilerOptions14,
11875
		compilerOptions14,
11876
		null);
11876
		null);
11877
}
11877
}
11878
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=332744 (all 1.5+)
11879
public void test332744() {
11880
	Map compilerOptions15 = getCompilerOptions();
11881
	compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_5);
11882
	compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
11883
	compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5);
11884
	this.runConformTest(
11885
		new String[] {
11886
			"EList.java",
11887
			"import java.util.List;\n" +
11888
			"public interface EList<E> extends List<E> {\n" +
11889
			"}\n",
11890
			"FeatureMap.java",
11891
			"public interface FeatureMap extends EList<FeatureMap.Entry> {\n" +
11892
			"    interface Entry {\n" +
11893
			"    }\n" +
11894
			"}\n",
11895
			"InternalEList.java",
11896
			"public interface InternalEList<E> extends EList<E> {\n" +
11897
			"}\n"
11898
		},
11899
		"",
11900
		null,
11901
		true,
11902
		null,
11903
		compilerOptions15,
11904
		null);
11905
11906
	this.runConformTest(
11907
		new String[] {
11908
			"Client.java",
11909
			"public class Client {\n" +
11910
			"    Client(FeatureMap fm) {\n" +
11911
			"		InternalEList e = (InternalEList) fm;\n" +
11912
			"	}\n" +
11913
			"}\n"
11914
			},
11915
		"",
11916
		null,
11917
		false,
11918
		null,
11919
		compilerOptions15,
11920
		null);
11921
}
11922
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=332744 (1.4/1.5 mix)
11923
public void test332744b() {
11924
	Map compilerOptions15 = getCompilerOptions();
11925
	compilerOptions15.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, CompilerOptions.VERSION_1_5);
11926
	compilerOptions15.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
11927
	compilerOptions15.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5);
11928
	this.runConformTest(
11929
		new String[] {
11930
			"EList.java",
11931
			"import java.util.List;\n" +
11932
			"public interface EList<E> extends List<E> {\n" +
11933
			"}\n",
11934
			"FeatureMap.java",
11935
			"public interface FeatureMap extends EList<FeatureMap.Entry> {\n" +
11936
			"    interface Entry {\n" +
11937
			"    }\n" +
11938
			"}\n",
11939
			"InternalEList.java",
11940
			"public interface InternalEList<E> extends EList<E> {\n" +
11941
			"}\n"
11942
		},
11943
		"",
11944
		null,
11945
		true,
11946
		null,
11947
		compilerOptions15,
11948
		null);
11949
11950
	Map compilerOptions14 = getCompilerOptions();
11951
	compilerOptions14.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2);
11952
	compilerOptions14.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4);
11953
	compilerOptions14.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3);
11954
	compilerOptions14.put(JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK, JavaCore.IGNORE);
11955
	this.runConformTest(
11956
		new String[] {
11957
			"Client.java",
11958
			"public class Client {\n" +
11959
			"    Client(FeatureMap fm) {\n" +
11960
			"		InternalEList e = (InternalEList) fm;\n" +
11961
			"	}\n" +
11962
			"}\n"
11963
			},
11964
		"",
11965
		null,
11966
		false,
11967
		null,
11968
		compilerOptions14,
11969
		null);
11970
}
11878
}
11971
}

Return to bug 332744