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

Calling "each" on an untyped model variable with two arguments causes doCall error

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.4, 2.4.0-rc-1
    • 5.0.0-alpha-1
    • None
    • None

    Description

      With the following code, the markup builder will recognize a call to the each method, but at runtime, it throws an error:

      MarkupTemplateEngine engine = new MarkupTemplateEngine(new TemplateConfiguration())
      
              def template = engine.createTemplate '''
                  groups.each { k, v -> li(k) }
              '''
              def model = [groups:[a:'Group a',b:'Group b']]
              String rendered = template.make(model)
      

      The error is:

      groovy.lang.MissingMethodException: No signature of method: GeneratedMarkupTemplate0$_run_closure1.doCall() is applicable for argument types: (java.util.LinkedHashMap$Entry) values: [a=Group a]
      Possible solutions: doCall(java.lang.Object, java.lang.Object), findAll(), findAll(), isCase(java.lang.Object), isCase(java.lang.Object)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:270)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:910)
      	at groovy.lang.Closure.call(Closure.java:423)
      	at groovy.lang.Closure.call(Closure.java:439)
      	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1380)
      	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1311)
      	at GeneratedMarkupTemplate0.run(GeneratedMarkupTemplate0:2)
      	at groovy.text.markup.BaseTemplate.writeTo(BaseTemplate.java:468)
      	at groovy.lang.Writable$writeTo.call(Unknown Source)
      

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              melix Cédric Champeau
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: