Groovy
  1. Groovy
  2. GROOVY-4731

sample code in javadoc of Map#spreadMap() don't works

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.8-rc-4
    • Component/s: groovy-jdk
    • Labels:
      None

      Description

      At the GDK document of Map#toSpreadMap(),

      http://groovy.codehaus.org/groovy-jdk/java/util/Map.html#toSpreadMap()

      says:

      For examples, if there is defined a function like as

      def fn(a, b, c, d)

      Unknown macro: { return a + b + c + d }

      , then all of the following three have the same meaning.
      println fn(a:1, [b:2, c:3].toSpreadMap(), d:4)
      println fn(a:1, *:[b:2, c:3], d:4)
      println fn(a:1, b:2, c:3, d:4)

      I think there are at least 2 problems here.

      1) fn should take Map parameter like:

      def fn(Map m) { return m.a + m.b + m.c + m.d }

      2) I changed it in 1) way but I get following error at the line calling toSpreadMap().

      Caught: groovy.lang.MissingMethodException: No signature of method: d.fn() is applicable for argument types: (java.util.LinkedHashMap, groovy.lang.SpreadMap) values: [[a:1, d:4], [:]]
      Possible solutions: fn(java.util.Map), run(), run(), any(), run(java.io.File, [Ljava.lang.String, any(groovy.lang.Closure)
      at d.run(d.groovy:3)

        Activity

        UEHARA Junji created issue -
        Paul King made changes -
        Field Original Value New Value
        Resolution Fixed [ 1 ]
        Assignee Paul King [ paulk ]
        Fix Version/s 1.8-rc-4 [ 17245 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12733661 ] Default workflow, editable Closed status [ 12745462 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12971173 ] Default workflow, editable Closed status [ 12978924 ]

          People

          • Assignee:
            Paul King
            Reporter:
            UEHARA Junji
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development