Christopher Smith created GROOVY-11276:
------------------------------------------

             Summary: Generics error in method resolution
                 Key: GROOVY-11276
                 URL: https://issues.apache.org/jira/browse/GROOVY-11276
             Project: Groovy
          Issue Type: Bug
          Components: Static Type Checker
    Affects Versions: 4.0.17
            Reporter: Christopher Smith


There's a chance this is a duplicate of a ticket recently fixed, but it's odd 
enough (and the message is unclear enough) that I'm reposting it.

{code}
Map<String, List<String>> idsForAccounts(Collection<String> persons) {
  Map<Object, Object> fromGraph = retrieve()

  // workaround for buggy database implementation follows
  new HashMap<String, List<String>>().tap { result ->
    putAll(fromGraph as Map<String, List<String>>)
    persons.forEach {
      if (!result.containsKey(it)) {
        result.put(it, emptyList())
      }
    }
  }
}
{code}

{code}
[Static type checking] - Cannot find matching method 
java.util.HashMap#put(java.lang.String, java.util.List<#T>). Please check if 
the declared type is correct and if the method exists.
  @ line 73, column 21.
        result.put(it, emptyList())
        ^
{code}



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

Reply via email to