Community
Participate
Working Groups
3.5M1 In compliance 1.5 but source level 1.4, the following code should be rejected, but Eclipse does accept it incorrectly. public class X { void foo(long[] longs) throws Exception { long[] other = longs.clone(); } } should report type mismatch: ---------- 1. ERROR in X.java (at line 3) long[] other = longs.clone(); ^^^^^^^^^^^^^ Type mismatch: cannot convert from Object to long[] ----------
Created attachment 112557 [details] Test patch
Created attachment 112567 [details] Better regression tests Added ArrayTest#test014-017
Change being combined with bug 247292. Specific fix takes place in 2 places: MessageSend#computeConversion(...) following portion should refer to sourceLevel instead of complianceLevel: } else if (this.actualReceiverType.isArrayType() && runtimeTimeType.id != TypeIds.T_JavaLangObject && this.binding.parameters == Binding.NO_PARAMETERS && scope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_5 && CharOperation.equals(this.binding.selector, TypeConstants.CLONE)) { // from 1.5 compliant mode on, array#clone() resolves to array type, but codegen to #clone()Object - thus require extra inserted cast this.valueCast = runtimeTimeType;
also MessageSend#resolveType(...) should refer to sourceLevel instead of complianceLevel in following code: // from 1.5 compliance on, array#clone() returns the array type (but binding still shows Object) if (this.actualReceiverType.isArrayType() && this.binding.parameters == Binding.NO_PARAMETERS && compilerOptions.complianceLevel >= ClassFileConstants.JDK1_5 && CharOperation.equals(this.binding.selector, TypeConstants.CLONE)) { this.resolvedType = this.actualReceiverType;
Released for 3.5M3. Fixed
Verified for 3.5M3 using I20081026-2000 build.