eric-milles commented on a change in pull request #1561:
URL: https://github.com/apache/groovy/pull/1561#discussion_r613556096



##########
File path: src/main/java/org/codehaus/groovy/classgen/asm/OperandStack.java
##########
@@ -331,19 +332,13 @@ private void doConvertAndCast(ClassNode targetType, final 
boolean coerce) {
 
         ClassNode top = stack.get(size - 1);
         targetType = targetType.redirect();
-        if (targetType == top) return;
+        if (ClassNodeUtils.isCompatibleWith(top, targetType)) return;
 
         if (coerce) {
             controller.getInvocationWriter().coerce(top, targetType);
             return;
         }
 
-        // GROOVY-10034: no need to cast non-primitive array when target is 
"java.lang.Object[]"
-        if (targetType.isArray() && 
targetType.getComponentType().equals(ClassHelper.OBJECT_TYPE)
-                && top.isArray() && 
!ClassHelper.isPrimitiveType(top.getComponentType())) {
-            return;
-        }

Review comment:
       I thought the goal was to simplify from GROOVY-10034.  Now we have 
multiple new public APIs to support?  `Object[]` can accept any kind of array 
regardless of dimension, except one-dimensional primitive array.  This was 
accounted for in the original condition.
   
   `targetType == top` is a much faster comparison then always making a method 
call.  `==` or `.equals` should probably be kept before making a method call.




-- 
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]


Reply via email to