Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 359832

Summary: Arrays being compared to null are being boxed
Product: z_Archived Reporter: Matt Heitz <mheitz>
Component: EDTAssignee: Project Inbox <edt.compiler-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P1 CC: jeffdouglas, pharmon
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Matt Heitz CLA 2011-10-04 09:09:42 EDT
If I have array == null, array != null, null == array, or null != array, the array variable is wrapped in a BoxingExpression.  References like arrays should never be boxed.  Since it's not supposed to work, the code we generate doesn't compile.
Comment 1 Jeff Douglas CLA 2011-10-04 09:29:30 EDT
It's not quite true that boxing should never occur on arrays, as if they are using as an argument to an inout function parm, then the array needs to be boxed and unboxed to pass the pointer around.

I looked at the defect further however, and the BoxingExpression is being created by IRUtils.makeCompatible, in this code:

	public static void makeCompatible(BinaryExpression expr, Type type1, Type type2) {
		Operation op = expr.getOperation();
		Expression asExpr;
		Type parmType1 = op.getParameters().get(0).getType();
		Type parmType2 = op.getParameters().get(1).getType();
		// Operation invocations never have ParameterizedType(s) as parameter types
		// so always use the classifier instead of the type directly
		
		
		if (type1 != null && !type1.getClassifier().equals(parmType1)) {
			asExpr = makeExprCompatibleToType(expr.getLHS(), parmType1);
			expr.setLHS(asExpr);
		}
Comment 2 Paul Harmon CLA 2011-11-01 12:10:12 EDT
I have updated IRUtils so that no boxing expression is created when either of the operands of a binary expression is a NullType
Comment 3 Matt Heitz CLA 2011-11-16 11:07:23 EST
Verified.