Community
Participate
Working Groups
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.
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); }
I have updated IRUtils so that no boxing expression is created when either of the operands of a binary expression is a NullType
Verified.