You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2021/10/11 17:41:00 UTC

[jira] [Commented] (GROOVY-9375) Cannot call method with Map parameter

    [ https://issues.apache.org/jira/browse/GROOVY-9375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17427275#comment-17427275 ] 

Eric Milles commented on GROOVY-9375:
-------------------------------------

"foo(a: inner)" case was fixed in Groovy 4.0a3.  See GROOVY-7106, et al.

> Cannot call method with Map parameter
> -------------------------------------
>
>                 Key: GROOVY-9375
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9375
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 2.5.9
>            Reporter: Daniil Ovchinnikov
>            Priority: Major
>
> {code}
> def foo(Map<String, Map<String, Object>> m) { m }
> @groovy.transform.CompileStatic
> def csUsage() {
>     Map<String, Object> inner = new LinkedHashMap<>()
>     inner.put("b", 42)
>     Map<String, Map<String, Object>> outer = new LinkedHashMap<>()
>     outer.put("a", inner)
>     foo(outer)
>     foo(a: inner)        // error
>     foo(a: [b: 42])      // error
>     foo([a: [b: 42]])    // error
> }
> csUsage()
> {code}
> Expected: no errors.
> The same error is reported on the lines with {{error}} comment: 
> {noformat}
> [Static type checking] - Cannot call script#foo(java.util.Map <java.lang.String, java.util.Map>) with arguments [java.util.LinkedHashMap <java.lang.String, java.util.LinkedHashMap>] 
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)