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

@CompileStatic fails to compile Map.each { key, value -> } form

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: 2.0.1
    • Component/s: Static compilation
    • Labels:
    • Environment:
      Ubuntu 12.04, Oracle JDK 1.7.0_05-b05

      Description

      The following code (from Map#each documentation in the Groovy JDK) fails under static compilation:

      import groovy.transform.CompileStatic
      
      @CompileStatic def test() {
          def result = ""
          [a:1, b:3].each { key, value -> result += "$key$value" }
          assert result == "a1b3"
      }
      test()
      

      with the message:

      Caught: groovy.lang.MissingMethodException: No signature of method: mapeach$_test_closure1.doCall() is applicable for argument types: (java.util.LinkedHashMap$Entry) values: [a=1]
      Possible solutions: doCall(java.lang.Object, java.lang.Object), findAll(), findAll(), isCase(java.lang.Object), isCase(java.lang.Object)
      groovy.lang.MissingMethodException: No signature of method: mapeach$_test_closure1.doCall() is applicable for argument types: (java.util.LinkedHashMap$Entry) values: [a=1]
      Possible solutions: doCall(java.lang.Object, java.lang.Object), findAll(), findAll(), isCase(java.lang.Object), isCase(java.lang.Object)
      	at mapeach.test(mapeach.groovy:5)
      	at mapeach.run(mapeach.groovy:8)
      

        Attachments

        1. BrokenCompileStaticTest.groovy
          0.2 kB
          Steven Ruppert

          Activity

            People

            • Assignee:
              melix C├ędric Champeau
              Reporter:
              blendmaster Steven Ruppert
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: