You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2024/03/09 13:40:18 UTC

(groovy) branch GROOVY_3_0_X updated (f89bb668d4 -> c917668243)

This is an automated email from the ASF dual-hosted git repository.

emilles pushed a change to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git


    from f89bb668d4 make non-indy test more lenient (both non and indy cases)
     new 81ea3227e2 GROOVY-11270: reduce "foo.bar.Baz" to "f.b.Baz" in long error message
     new c917668243 GROOVY-11335: STC: loop item type from `UnionTypeClassNode`

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/groovy/lang/MissingMethodException.java   |   4 +-
 .../org/codehaus/groovy/runtime/InvokerHelper.java |  43 +++++++--
 .../transform/stc/StaticTypeCheckingVisitor.java   |  47 ++++-----
 .../groovy/transform/stc/UnionTypeClassNode.java   |  98 +++++++++----------
 src/test/groovy/transform/stc/LoopsSTCTest.groovy  |  14 +++
 .../codehaus/groovy/runtime/InvokerHelperTest.java | 106 +++++++++++++--------
 6 files changed, 185 insertions(+), 127 deletions(-)


(groovy) 02/02: GROOVY-11335: STC: loop item type from `UnionTypeClassNode`

Posted by em...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit c917668243d74746bb0ddfef96de61da0bcf2b75
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Fri Mar 8 17:37:53 2024 -0600

    GROOVY-11335: STC: loop item type from `UnionTypeClassNode`
    
    3_0_X backport
---
 .../transform/stc/StaticTypeCheckingVisitor.java   | 47 ++++++-----
 .../groovy/transform/stc/UnionTypeClassNode.java   | 98 ++++++++++------------
 src/test/groovy/transform/stc/LoopsSTCTest.groovy  | 14 ++++
 3 files changed, 83 insertions(+), 76 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index 04a7a4be28..9da79a987a 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -1985,26 +1985,27 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
      * @see #inferComponentType
      */
     public static ClassNode inferLoopElementType(final ClassNode collectionType) {
-        ClassNode componentType = collectionType.getComponentType();
-        if (componentType == null) {
-            if (implementsInterfaceOrIsSubclassOf(collectionType, ITERABLE_TYPE)) {
-                ClassNode col = GenericsUtils.parameterizeType(collectionType, ITERABLE_TYPE);
-                componentType = col.getGenericsTypes()[0].getType();
-
-            } else if (implementsInterfaceOrIsSubclassOf(collectionType, MAP_TYPE)) { // GROOVY-6240
-                ClassNode col = GenericsUtils.parameterizeType(collectionType, MAP_TYPE);
-                componentType = MAP_ENTRY_TYPE.getPlainNodeReference();
-                componentType.setGenericsTypes(col.getGenericsTypes());
-
-            } else if (implementsInterfaceOrIsSubclassOf(collectionType, ENUMERATION_TYPE)) { // GROOVY-6123
-                ClassNode col = GenericsUtils.parameterizeType(collectionType, ENUMERATION_TYPE);
-                componentType = col.getGenericsTypes()[0].getType();
-
-            } else if (collectionType.equals(STRING_TYPE)) {
-                componentType = STRING_TYPE;
-            } else {
-                componentType = OBJECT_TYPE;
-            }
+        ClassNode componentType;
+        if (collectionType.isArray()) { // GROOVY-11335
+            componentType = collectionType.getComponentType();
+
+        } else if (implementsInterfaceOrIsSubclassOf(collectionType, ITERABLE_TYPE)) {
+            ClassNode col = GenericsUtils.parameterizeType(collectionType, ITERABLE_TYPE);
+            componentType = col.getGenericsTypes()[0].getType();
+
+        } else if (implementsInterfaceOrIsSubclassOf(collectionType, MAP_TYPE)) { // GROOVY-6240
+            ClassNode col = GenericsUtils.parameterizeType(collectionType, MAP_TYPE);
+            componentType = MAP_ENTRY_TYPE.getPlainNodeReference();
+            componentType.setGenericsTypes(col.getGenericsTypes());
+
+        } else if (implementsInterfaceOrIsSubclassOf(collectionType, ENUMERATION_TYPE)) { // GROOVY-6123
+            ClassNode col = GenericsUtils.parameterizeType(collectionType, ENUMERATION_TYPE);
+            componentType = col.getGenericsTypes()[0].getType();
+
+        } else if (collectionType.equals(STRING_TYPE)) {
+            componentType = STRING_TYPE;
+        } else {
+            componentType = OBJECT_TYPE;
         }
         return componentType;
     }
@@ -4692,8 +4693,10 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
     }
 
     protected ClassNode inferComponentType(final ClassNode containerType, final ClassNode indexType) {
-        ClassNode componentType = containerType.getComponentType();
-        if (componentType == null) {
+        ClassNode componentType = null;
+        if (containerType.isArray()) { // GROOVY-11335
+            componentType = containerType.getComponentType();
+        } else {
             // GROOVY-5521: check for "getAt" method
             typeCheckingContext.pushErrorCollector();
             MethodCallExpression vcall = callX(localVarX("_hash_", containerType), "getAt", varX("_index_", indexType));
diff --git a/src/main/java/org/codehaus/groovy/transform/stc/UnionTypeClassNode.java b/src/main/java/org/codehaus/groovy/transform/stc/UnionTypeClassNode.java
index b4aa4154e0..ab402af70a 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/UnionTypeClassNode.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/UnionTypeClassNode.java
@@ -35,7 +35,6 @@ import org.codehaus.groovy.ast.stmt.Statement;
 import org.codehaus.groovy.transform.ASTTransformation;
 
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
@@ -172,59 +171,51 @@ class UnionTypeClassNode extends ClassNode {
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public boolean declaresInterface(final ClassNode classNode) {
-        for (ClassNode delegate : delegates) {
-            if (delegate.declaresInterface(classNode)) return true;
-        }
-        return false;
-    }
-
     @Override
     public List<MethodNode> getAbstractMethods() {
-        List<MethodNode> allMethods = new LinkedList<MethodNode>();
+        List<MethodNode> answer = new LinkedList<>();
         for (ClassNode delegate : delegates) {
-            allMethods.addAll(delegate.getAbstractMethods());
+            answer.addAll(delegate.getAbstractMethods());
         }
-        return allMethods;
+        return answer;
     }
 
     @Override
     public List<MethodNode> getAllDeclaredMethods() {
-        List<MethodNode> allMethods = new LinkedList<MethodNode>();
+        List<MethodNode> answer = new LinkedList<>();
         for (ClassNode delegate : delegates) {
-            allMethods.addAll(delegate.getAllDeclaredMethods());
+            answer.addAll(delegate.getAllDeclaredMethods());
         }
-        return allMethods;
+        return answer;
     }
 
     @Override
     public Set<ClassNode> getAllInterfaces() {
-        Set<ClassNode> allMethods = new HashSet<ClassNode>();
+        Set<ClassNode> answer = new HashSet<>();
         for (ClassNode delegate : delegates) {
-            allMethods.addAll(delegate.getAllInterfaces());
+            answer.addAll(delegate.getAllInterfaces());
         }
-        return allMethods;
+        return answer;
     }
 
     @Override
     public List<AnnotationNode> getAnnotations() {
-        List<AnnotationNode> nodes = new LinkedList<AnnotationNode>();
+        List<AnnotationNode> answer = new LinkedList<>();
         for (ClassNode delegate : delegates) {
             List<AnnotationNode> annotations = delegate.getAnnotations();
-            if (annotations != null) nodes.addAll(annotations);
+            if (annotations != null) answer.addAll(annotations);
         }
-        return nodes;
+        return answer;
     }
 
     @Override
     public List<AnnotationNode> getAnnotations(final ClassNode type) {
-        List<AnnotationNode> nodes = new LinkedList<AnnotationNode>();
+        List<AnnotationNode> answer = new LinkedList<>();
         for (ClassNode delegate : delegates) {
             List<AnnotationNode> annotations = delegate.getAnnotations(type);
-            if (annotations != null) nodes.addAll(annotations);
+            if (annotations != null) answer.addAll(annotations);
         }
-        return nodes;
+        return answer;
     }
 
     @Override
@@ -234,11 +225,11 @@ class UnionTypeClassNode extends ClassNode {
 
     @Override
     public List<ConstructorNode> getDeclaredConstructors() {
-        List<ConstructorNode> nodes = new LinkedList<ConstructorNode>();
+        List<ConstructorNode> answer = new LinkedList<>();
         for (ClassNode delegate : delegates) {
-            nodes.addAll(delegate.getDeclaredConstructors());
+            answer.addAll(delegate.getDeclaredConstructors());
         }
-        return nodes;
+        return answer;
     }
 
     @Override
@@ -261,12 +252,12 @@ class UnionTypeClassNode extends ClassNode {
 
     @Override
     public List<MethodNode> getDeclaredMethods(final String name) {
-        List<MethodNode> nodes = new LinkedList<MethodNode>();
+        List<MethodNode> answer = new LinkedList<>();
         for (ClassNode delegate : delegates) {
             List<MethodNode> methods = delegate.getDeclaredMethods(name);
-            if (methods != null) nodes.addAll(methods);
+            if (methods != null) answer.addAll(methods);
         }
-        return nodes;
+        return answer;
     }
 
     @Override
@@ -290,12 +281,12 @@ class UnionTypeClassNode extends ClassNode {
 
     @Override
     public List<FieldNode> getFields() {
-        List<FieldNode> nodes = new LinkedList<FieldNode>();
+        List<FieldNode> answer = new LinkedList<>();
         for (ClassNode delegate : delegates) {
             List<FieldNode> fields = delegate.getFields();
-            if (fields != null) nodes.addAll(fields);
+            if (fields != null) answer.addAll(fields);
         }
-        return nodes;
+        return answer;
     }
 
     @Override
@@ -305,22 +296,25 @@ class UnionTypeClassNode extends ClassNode {
 
     @Override
     public ClassNode[] getInterfaces() {
-        Set<ClassNode> nodes = new LinkedHashSet<ClassNode>();
+        Set<ClassNode> answer = new LinkedHashSet<>();
         for (ClassNode delegate : delegates) {
-            ClassNode[] interfaces = delegate.getInterfaces();
-            if (interfaces != null) Collections.addAll(nodes, interfaces);
+            if (delegate.isInterface()) {
+                answer.remove(delegate); answer.add(delegate);
+            } else {
+                answer.addAll(Arrays.asList(delegate.getInterfaces()));
+            }
         }
-        return nodes.toArray(ClassNode.EMPTY_ARRAY);
+        return answer.toArray(ClassNode.EMPTY_ARRAY);
     }
 
     @Override
     public List<MethodNode> getMethods() {
-        List<MethodNode> nodes = new LinkedList<MethodNode>();
+        List<MethodNode> answer = new LinkedList<>();
         for (ClassNode delegate : delegates) {
             List<MethodNode> methods = delegate.getMethods();
-            if (methods != null) nodes.addAll(methods);
+            if (methods != null) answer.addAll(methods);
         }
-        return nodes;
+        return answer;
     }
 
     @Override
@@ -334,12 +328,12 @@ class UnionTypeClassNode extends ClassNode {
 
     @Override
     public List<PropertyNode> getProperties() {
-        List<PropertyNode> nodes = new LinkedList<PropertyNode>();
+        List<PropertyNode> answer = new LinkedList<>();
         for (ClassNode delegate : delegates) {
             List<PropertyNode> properties = delegate.getProperties();
-            if (properties != null) nodes.addAll(properties);
+            if (properties != null) answer.addAll(properties);
         }
-        return nodes;
+        return answer;
     }
 
     @Override
@@ -349,22 +343,18 @@ class UnionTypeClassNode extends ClassNode {
 
     @Override
     public ClassNode[] getUnresolvedInterfaces() {
-        Set<ClassNode> nodes = new LinkedHashSet<ClassNode>();
-        for (ClassNode delegate : delegates) {
-            ClassNode[] interfaces = delegate.getUnresolvedInterfaces();
-            if (interfaces != null) Collections.addAll(nodes, interfaces);
-        }
-        return nodes.toArray(ClassNode.EMPTY_ARRAY);
+        return getUnresolvedInterfaces(false);
     }
 
     @Override
     public ClassNode[] getUnresolvedInterfaces(final boolean useRedirect) {
-        Set<ClassNode> nodes = new LinkedHashSet<ClassNode>();
-        for (ClassNode delegate : delegates) {
-            ClassNode[] interfaces = delegate.getUnresolvedInterfaces(useRedirect);
-            if (interfaces != null) Collections.addAll(nodes, interfaces);
+        ClassNode[] interfaces = getInterfaces();
+        if (useRedirect) {
+            for (int i = 0; i < interfaces.length; ++i) {
+                interfaces[i] = interfaces[i].redirect();
+            }
         }
-        return nodes.toArray(ClassNode.EMPTY_ARRAY);
+        return interfaces;
     }
 
     @Override
diff --git a/src/test/groovy/transform/stc/LoopsSTCTest.groovy b/src/test/groovy/transform/stc/LoopsSTCTest.groovy
index dd159a4a2a..4dd61a129f 100644
--- a/src/test/groovy/transform/stc/LoopsSTCTest.groovy
+++ b/src/test/groovy/transform/stc/LoopsSTCTest.groovy
@@ -225,6 +225,20 @@ class LoopsSTCTest extends StaticTypeCheckingTestCase {
         '''
     }
 
+    // GROOVY-11335
+    void testForInLoopOnCollection() {
+        assertScript '''
+            def whatever(Collection<String> coll) {
+                if (coll instanceof Serializable) {
+                    for (item in coll) {
+                        return item.toLowerCase()
+                    }
+                }
+            }
+            assert whatever(['Works']) == 'works'
+        '''
+    }
+
     // GROOVY-6123
     void testForInLoopOnEnumeration() {
         assertScript '''


(groovy) 01/02: GROOVY-11270: reduce "foo.bar.Baz" to "f.b.Baz" in long error message

Posted by em...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 81ea3227e2dd0246f4a76632638af023cf03f423
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Fri Mar 8 18:48:17 2024 -0600

    GROOVY-11270: reduce "foo.bar.Baz" to "f.b.Baz" in long error message
    
    3_0_X backport
---
 .../java/groovy/lang/MissingMethodException.java   |   4 +-
 .../org/codehaus/groovy/runtime/InvokerHelper.java |  43 +++++++--
 .../codehaus/groovy/runtime/InvokerHelperTest.java | 106 +++++++++++++--------
 3 files changed, 102 insertions(+), 51 deletions(-)

diff --git a/src/main/java/groovy/lang/MissingMethodException.java b/src/main/java/groovy/lang/MissingMethodException.java
index 6a9a857065..072b8ecc76 100644
--- a/src/main/java/groovy/lang/MissingMethodException.java
+++ b/src/main/java/groovy/lang/MissingMethodException.java
@@ -60,9 +60,9 @@ public class MissingMethodException extends GroovyRuntimeException {
                 + "."
                 + method
                 + "() is applicable for argument types: ("
-                + InvokerHelper.toTypeString(arguments, 60)
+                + InvokerHelper.toTypeString(arguments, 80)
                 + ") values: "
-                + InvokerHelper.toArrayString(arguments, 60, true)
+                + InvokerHelper.toArrayString(arguments, 80, true)
                 + (type != null ? MethodRankHelper.getMethodSuggestionString(method, type, arguments) : "");
     }
 
diff --git a/src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java b/src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java
index 6d3afec018..bbb45c4cfb 100644
--- a/src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java
+++ b/src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java
@@ -795,19 +795,42 @@ public class InvokerHelper {
         if (arguments == null) {
             return "null";
         }
-        StringBuilder argBuf = new StringBuilder();
-        for (int i = 0; i < arguments.length; i++) {
-            if (maxSize != -1 && argBuf.length() > maxSize) {
-                argBuf.append("...");
-                break;
-            } else {
-                if (i > 0) {
-                    argBuf.append(", ");
+        if (arguments.length == 0) {
+            return "";
+        }
+        if (maxSize < 0) {
+            return Arrays.stream(arguments)
+                    .map(arg -> arg != null ? typeName(arg) : "null")
+                    .collect(java.util.stream.Collectors.joining(", "));
+        }
+
+        StringBuilder plainForm = new StringBuilder();
+        StringBuilder shortForm = new StringBuilder();
+        for (int i = 0; i < arguments.length; i += 1) {
+            String type = arguments[i] != null ? typeName(arguments[i]) : "null";
+
+            if (plainForm.length() < maxSize) {
+                if (i > 0) plainForm.append(", ");
+                plainForm.append(type);
+            } else if (plainForm.charAt(plainForm.length() - 1) != '.') {
+                plainForm.append("...");
+            }
+
+            if (shortForm.length() < maxSize) {
+                if (i > 0) shortForm.append(", ");
+                String[] tokens = type.split("\\.");
+                for (int j = 0; j < tokens.length - 1; j += 1) {
+                    // GROOVY-11270: reduce "foo.bar.Baz" to "f.b.Baz"
+                    shortForm.appendCodePoint(tokens[j].codePointAt(0)).append('.');
                 }
-                argBuf.append(arguments[i] != null ? typeName(arguments[i]) : "null");
+                shortForm.append(tokens[tokens.length - 1]);
+            } else {
+                shortForm.append("...");
+                break;
             }
         }
-        return argBuf.toString();
+
+        return (plainForm.length() <= maxSize ? plainForm : shortForm).toString();
     }
 
     private static final Set<String> DEFAULT_IMPORT_PKGS = new HashSet<String>();
diff --git a/src/test/org/codehaus/groovy/runtime/InvokerHelperTest.java b/src/test/org/codehaus/groovy/runtime/InvokerHelperTest.java
index d80ae1437d..5ea13597ec 100644
--- a/src/test/org/codehaus/groovy/runtime/InvokerHelperTest.java
+++ b/src/test/org/codehaus/groovy/runtime/InvokerHelperTest.java
@@ -22,57 +22,85 @@ import groovy.lang.Binding;
 import groovy.lang.GroovyClassLoader;
 import groovy.lang.GroovyCodeSource;
 import groovy.lang.Script;
-import junit.framework.TestCase;
+import org.junit.Test;
 
 import java.util.HashMap;
+import java.util.Map;
 
-import static org.codehaus.groovy.runtime.InvokerHelper.initialCapacity;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
 
+public final class InvokerHelperTest {
 
-public class InvokerHelperTest extends TestCase {
-    private HashMap bindingVariables;
+    private final Map<String, Object> variables = new HashMap<>();
 
-    protected void setUp() throws Exception {
-        bindingVariables = new HashMap();
-        bindingVariables.put("name", "hans");
+    @Test
+    public void testCreateScriptWithScriptClass() throws Exception {
+        try (GroovyClassLoader classLoader = new GroovyClassLoader()) {
+            String controlProperty = "text", controlValue = "I am a script";
+            Class<?> scriptClass = classLoader.parseClass(new GroovyCodeSource(
+                    controlProperty + " = '" + controlValue + "'", "testscript", "/groovy/shell"), false);
+
+            Script script = InvokerHelper.createScript(scriptClass, new Binding(variables));
+
+            assertSame(variables, script.getBinding().getVariables());
+
+            script.run();
+
+            assertEquals(controlValue, script.getProperty(controlProperty));
+        }
     }
 
+    @Test
     public void testCreateScriptWithNullClass() {
-        Script script = InvokerHelper.createScript(null, new Binding(bindingVariables));
-        assertEquals(bindingVariables, script.getBinding().getVariables());
-    }
+        Script script = InvokerHelper.createScript(null, new Binding(variables));
 
-    public void testCreateScriptWithScriptClass() {
-        GroovyClassLoader classLoader = new GroovyClassLoader();
-        String controlProperty = "text";
-        String controlValue = "I am a script";
-        String code = controlProperty + " = '" + controlValue + "'";
-        GroovyCodeSource codeSource = new GroovyCodeSource(code, "testscript", "/groovy/shell");
-        Class scriptClass = classLoader.parseClass(codeSource, false);
-        Script script = InvokerHelper.createScript(scriptClass, new Binding(bindingVariables));
-        assertEquals(bindingVariables, script.getBinding().getVariables());
-        script.run();
-        assertEquals(controlValue, script.getProperty(controlProperty));
+        assertSame(variables, script.getBinding().getVariables());
     }
 
+    @Test
     public void testInitialCapacity() {
-        assertEquals(16, initialCapacity(0));
-        assertEquals(2, initialCapacity(1));
-        assertEquals(4, initialCapacity(2));
-        assertEquals(4, initialCapacity(3));
-        assertEquals(8, initialCapacity(4));
-        assertEquals(8, initialCapacity(5));
-        assertEquals(8, initialCapacity(6));
-        assertEquals(8, initialCapacity(7));
-        assertEquals(16, initialCapacity(8));
-        assertEquals(16, initialCapacity(9));
-        assertEquals(16, initialCapacity(10));
-        assertEquals(16, initialCapacity(11));
-        assertEquals(16, initialCapacity(12));
-        assertEquals(16, initialCapacity(13));
-        assertEquals(16, initialCapacity(14));
-        assertEquals(16, initialCapacity(15));
-        assertEquals(32, initialCapacity(16));
-        assertEquals(32, initialCapacity(17));
+        assertEquals(16, InvokerHelper.initialCapacity(0));
+        assertEquals( 2, InvokerHelper.initialCapacity(1));
+        assertEquals( 4, InvokerHelper.initialCapacity(2));
+        assertEquals( 4, InvokerHelper.initialCapacity(3));
+        assertEquals( 8, InvokerHelper.initialCapacity(4));
+        assertEquals( 8, InvokerHelper.initialCapacity(5));
+        assertEquals( 8, InvokerHelper.initialCapacity(6));
+        assertEquals( 8, InvokerHelper.initialCapacity(7));
+        assertEquals(16, InvokerHelper.initialCapacity(8));
+        assertEquals(16, InvokerHelper.initialCapacity(9));
+        assertEquals(16, InvokerHelper.initialCapacity(10));
+        assertEquals(16, InvokerHelper.initialCapacity(11));
+        assertEquals(16, InvokerHelper.initialCapacity(12));
+        assertEquals(16, InvokerHelper.initialCapacity(13));
+        assertEquals(16, InvokerHelper.initialCapacity(14));
+        assertEquals(16, InvokerHelper.initialCapacity(15));
+        assertEquals(32, InvokerHelper.initialCapacity(16));
+        assertEquals(32, InvokerHelper.initialCapacity(17));
+    }
+
+    @Test
+    public void testToTypeString() {
+        Object[] objects = null;
+        assertEquals("null", InvokerHelper.toTypeString(objects, 42));
+
+        objects = new Object[0];
+        assertEquals("", InvokerHelper.toTypeString(objects, 42));
+
+        objects = new Object[] {null};
+        assertEquals("null", InvokerHelper.toTypeString(objects, 42));
+
+        objects = new Object[] {0};
+        assertEquals("Integer", InvokerHelper.toTypeString(objects, 42));
+
+        objects = new Object[] {0, 1d};
+        assertEquals("Integer, Double", InvokerHelper.toTypeString(objects, 42));
+
+        objects = new Object[] {new DummyBean(), new DummyBean()}; // GROOVY-11270
+        assertEquals("o.c.g.r.DummyBean, o.c.g.r.DummyBean", InvokerHelper.toTypeString(objects, 42));
+
+        objects = new Object[] {0f, new DummyBean()};
+        assertEquals("Float, org.codehaus.groovy.runtime.DummyBean", InvokerHelper.toTypeString(objects, 44));
     }
 }