Wilson Leung created GROOVY-11581:
-------------------------------------

             Summary: byte array casted to array list when calling parent 
method from nested class
                 Key: GROOVY-11581
                 URL: https://issues.apache.org/jira/browse/GROOVY-11581
             Project: Groovy
          Issue Type: Bug
    Affects Versions: 4.0.9
            Reporter: Wilson Leung


 
{code:java}
import groovy.transform.CompileDynamic

class Foo {
    void test() {
        def byteArr = 'FOO'.bytes
        (new NestedFoo()).printClass(byteArr)
    }
    
    private static bar(def val, def apple) {
        println "bar class: ${val.getClass()}"  // prints array list 
    }
    
    private static baz(def val) {
        println "baz class: ${val.getClass()}" // prints byte array
    }

    @CompileDynamic
    class NestedFoo {
        def printClass(def val) {
            println "nestedFoo class: ${val.getClass()}"
            bar(val, '')
            baz(val)
        }
    }
}

(new Foo()).test()
{code}

Byte arrays are being casted to an array list when calling a parent method from 
a dynamically compiled nested class.  In the code above the call to bar will 
cast the byte array to an array list. This does not happen in the call to baz. 
It seems like this only happens when the method called takes more than one arg. 
I was able to reproduce this in groovy 4.0.9, I have not tested this in earlier 
versions.

To reproduce

1) Nested class must be compiled dynamically
2) The parent method being called must take at least two arguments.  It does 
not get casted when the method takes a single argument.

 

 

 

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to