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

Misleading MissingMethodException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.0-beta-4
    • 1.1-rc-2
    • None
    • None

    Description

      ClosureDelegateTest.groovy:

      package org.mccrindle.groovy.spring;

      class ClosureDelegateTest extends GroovyTestCase {
      void testClosureDelegate() {
      cdb = new ClosureDelegateBuilder();
      try {
      cdb.one() {
      two(map: [ "key":
      three(key: "value", anotherkey: "anothervalue")

      { four() }

      ])
      }
      } catch(MissingMethodException e)

      { assertEquals("four", e.method); }

      }
      }

      ClosureDelegateBuilder.java:

      /*
       * Created on Mar 13, 2004
       */
      package org.mccrindle.groovy.spring;

      import java.util.Map;

      import groovy.lang.Closure;

      /**
       * @author jamie
       */
      public class ClosureDelegateBuilder {

          public void one(Closure closure)

      {         closure.setDelegate(this);         closure.call();     }
         
          public void two(Map map) {}
         
          public void three(Map map, Closure closure) {         closure.setDelegate(this);         closure.call();     }

      }

      results in the following MissingMethodException:

      groovy.lang.MissingMethodException: No such method: three for class:
      org.mccrindle.groovy.spring.ClosureDelegateTest$1 with arguments:
      [[key:value, anotherkey:anothervalue],
      org.mccrindle.groovy.spring.ClosureDelegateTest$2@353154]
              at groovy.lang.MetaClass.invokeMethod(MetaClass.java:271)

      whereas it should say that four() is the missing method...

      Attachments

        Activity

          People

            tug John Wilson
            jamiemc Jamie McCrindle
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: