Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 359832 - Arrays being compared to null are being boxed
Summary: Arrays being compared to null are being boxed
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: EDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P1 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-04 09:09 EDT by Matt Heitz CLA
Modified: 2017-02-23 14:19 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.