Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7274

Improve type inference for hash map -> Map<?, ?>

    XMLWordPrintableJSON

Details

    Description

      Currently we have to do this:

      @CompileStatic
      ...
      inserter.createNode([v: it.value, l: it.language] as Map<String, Object>, labelLabel)
      

      If not we'll get:

      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]
      

      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)

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              ceefour Hendy Irawan
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: