Issue Details (XML | Word | Printable)

Key: GROOVY-272
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: John Wilson
Reporter: Jamie McCrindle
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
groovy

Misleading MissingMethodException

Created: 14/Mar/04 07:34 AM   Updated: 29/Nov/07 08:12 PM
Component/s: None
Affects Version/s: 1.0-beta-4
Fix Version/s: 1.1-rc-2

Time Tracking:
Not Specified


 Description  « Hide
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...



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Paul King added a comment - 15/Oct/07 03:07 AM
Seems to work fine in HEAD