amaliujia commented on a change in pull request #1609: [CALCITE-3520] Type cast
from primitive to box is not correct
URL: https://github.com/apache/calcite/pull/1609#discussion_r351510329
##########
File path:
core/src/main/java/org/apache/calcite/adapter/enumerable/EnumUtils.java
##########
@@ -394,16 +392,6 @@ public static Expression convert(Expression operand, Type
fromType,
Expressions.unbox(operand, toBox),
toBox));
} else if (fromPrimitive != null && toBox != null) {
- // E.g. from "int" to "Long".
- // Generate Long.valueOf(x)
- // Eliminate primitive casts like Long.valueOf((long) x)
- if (operand instanceof UnaryExpression) {
- UnaryExpression una = (UnaryExpression) operand;
- if (una.nodeType == ExpressionType.Convert
- || Primitive.of(una.getType()) == toBox) {
- return Expressions.box(una.expression, toBox);
- }
- }
Review comment:
If you check the following lines, there is
```
// E.g., from "int" to "Byte".
// Convert it first and generate "Byte.valueOf((byte)x)"
// Because there is no method "Byte.valueOf(int)" in Byte
return Expressions.box(
Expressions.convert_(operand, toBox.primitiveClass),
toBox);
```
So the case was aware of already, and it just seems like cases should have
skipped this optimization fail to do so.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services