Eric Milles created GROOVY-8839: ----------------------------------- Summary: Static compilation and array type parameter causing compile error Key: GROOVY-8839 URL: https://issues.apache.org/jira/browse/GROOVY-8839 Project: Groovy Issue Type: Question Affects Versions: 2.4.15 Reporter: Eric Milles
This seems related to GROOVY-8342 (and possibly GROOVY-8638 and GROOVY-7985). When using an array in a generics parameter, I get compile errors for return of a map and also for assignment of return value to a variable. {code:java} package r; public class ResultHandle {} {code} {code:groovy} package p import groovy.transform.CompileStatic import r.ResultHandle @CompileStatic class Issue { protected Map<String, ResultHandle[]> getResultsByType() { Map<String, ResultHandle[]> resultsByType = [:] // populate resultsByType return resultsByType } } {code} When I build using Ant, I get the following error: {code} Buildfile: ...\Gr8\build.xml -init: -compile: [mkdir] Created dir: ...\Gr8\ant\JavaClasses [compile] Compiling 2 source files to ...\Gr8\ant\JavaClasses [compile] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: [compile] ...\Gr8\src\main\bugs\Groovy1234.groovy: 12: [Static type checking] - Incompatible generic argument types. Cannot assign java.util.LinkedHashMap <java.lang.String, [Lr.ResultHandle;> to: java.util.Map <String, ResultHandle[]> [compile] @ line 12, column 12. [compile] return resultsByType [compile] ^ [compile] 1 error BUILD FAILED {code} Additionally, I would get an error if I assigned the result of the method to a typed variable, like this: {{Map<String, ResultHandle[]> resultsByType = issue.getResultsByType()}} -- This message was sent by Atlassian JIRA (v7.6.3#76005)