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/03/31 01:10:00 UTC

[jira] [Resolved] (GROOVY-7274) Improve type inference for hash map -> Map

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

Eric Milles resolved GROOVY-7274.
---------------------------------
    Fix Version/s: 4.0.0-alpha-3
       Resolution: Fixed

> Improve type inference for hash map -> Map<?, ?>
> ------------------------------------------------
>
>                 Key: GROOVY-7274
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7274
>             Project: Groovy
>          Issue Type: Improvement
>          Components: Static compilation
>    Affects Versions: 2.4.0
>            Reporter: Hendy Irawan
>            Assignee: Eric Milles
>            Priority: Trivial
>             Fix For: 4.0.0-alpha-3
>
>
> Currently we have to do this:
> {code}
> @CompileStatic
> ...
> inserter.createNode([v: it.value, l: it.language] as Map<String, Object>, labelLabel)
> {code}
> If not we'll get:
> {code}
> Error:(81, 37) Groovyc: [Static type checking] - Cannot call org.neo4j.unsafe.batchinsert.BatchInserter#createNode(java.util.Map <java.lang.String, java.lang.Object>, org.neo4j.graphdb.Label[]) with arguments [java.util.LinkedHashMap <java.lang.String, java.lang.String>, org.neo4j.graphdb.Label]
> {code}
> But since the caller requests Map<String, Object>, Groovy can create the hashmap as <String, Object> instead of <String, String>... saving us from explicit type coercion even with {{@CompileStatic}}. (similar to Java7's diamond operator)



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