bug 433959 - Bogus checkcast when array lowering is also involved 
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java
index a1a7580..ae4972c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java
@@ -500,6 +500,13 @@
 	    		? compileTimeType  // unboxing: checkcast before conversion
 	    		: runtimeTimeType;
 	        this.valueCast = originalType.genericCast(targetType);
+//{ObjectTeams: don't try to let casting do the job of lowering:
+	        TypeBinding leafCompile = compileTimeType.leafComponentType();
+	        TypeBinding leafRuntime = runtimeTimeType.leafComponentType();
+	        if (!compileTimeType.isBaseType() && !runtimeTimeType.isBaseType()
+	        		&& ((ReferenceBinding)leafCompile).isCompatibleViaLowering((ReferenceBinding) leafRuntime))
+	        	this.valueCast = originalType.genericCast(compileTimeType);	        	
+// SH}
 		} 	else if (this.binding == scope.environment().arrayClone
 				&& runtimeTimeType.id != TypeIds.T_JavaLangObject
 				&& scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) {
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/roleplaying/LiftingAndLowering.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/roleplaying/LiftingAndLowering.java
index af8a3ea..ea1df30 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/roleplaying/LiftingAndLowering.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/roleplaying/LiftingAndLowering.java
@@ -2492,6 +2492,33 @@
                 });
     }
     
+    public void test2212_arrayLoweringToBaseclass9() {
+    	runConformTest(
+    		new String[] {
+    			"Team2214altb9.java",
+    			"import java.util.*;\n" +
+    			"public team class Team2214altb9 {\n" +
+    			"	protected class R playedBy T2214altb9 { protected R() { base(); } }\n" +
+    			"	T2214altb9[] toBaseArray(List<R> roles) {\n" +
+    			"		return roles.toArray(new R[roles.size()]);\n" +
+    			"	}\n" +
+    			"	void test() {\n" +
+    			"		List<R> roles = new ArrayList<R>();\n" +
+    			"		roles.add(new R());\n" +
+    			"		T2214altb9[] bases = toBaseArray(roles);\n" +
+    			"		System.out.println(bases[0].getClass().getName());\n" +
+    			"	}\n" +
+    			"	public static void main(String[] args) {\n" +
+    			"		new Team2214altb9().test();\n" +
+    			"	}\n" +
+    			"}\n",
+    			"T2214altb9.java",
+    			"public class T2214altb9 {\n" +
+    			"}\n"
+    		},
+    		"T2214altb9");
+    }
+    
     // lowering of a role object array for the same base objects produces the an equal object array
     // 2.2.14-otjld-array-lowering-produces-equal-object-1
     public void test2214_arrayLoweringProducesEqualObject1() {