You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2019/11/27 21:47:32 UTC

[GitHub] [calcite] amaliujia commented on a change in pull request #1609: [CALCITE-3520] Type cast from primitive to box is not correct

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 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:
users@infra.apache.org


With regards,
Apache Git Services