[ 
https://issues.apache.org/jira/browse/GROOVY-10938?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Eric Milles closed GROOVY-10938.
--------------------------------
    Fix Version/s: 4.x
       Resolution: Duplicate

> Cannot assign list to array under static compilation
> ----------------------------------------------------
>
>                 Key: GROOVY-10938
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10938
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 3.0.15
>            Reporter: Jason Garrett
>            Priority: Minor
>             Fix For: 4.x
>
>
> Assigning a List to an Array of the same type does not compile.
> This class:
> {code:java}
> package example
> import groovy.transform.CompileStatic
> @CompileStatic
> class AssignListToArray {
>    void doStuff(String[] data) {
>       data = data.collect { it }
>    }
> } {code}
> Results in this compilation error:
> {code:java}
> src/main/groovy/example/AssignListToArray.groovy: 8: [Static type checking] - 
> Cannot assign value of type java.util.List <java.lang.String> to variable of 
> type java.lang.String[]
>  @ line 8, column 10.
>            data = data.collect { it } {code}
> This class compiles in 2.4.21, 2.5.21, and 3.0.14.



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

Reply via email to