You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Daniil Ovchinnikov (Jira)" <ji...@apache.org> on 2020/01/27 15:54:00 UTC

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

Daniil Ovchinnikov created GROOVY-9375:
------------------------------------------

             Summary: 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


{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}

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)