groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pascal Schumacher (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-7456) Builders don't work in Traits
Date Wed, 01 Jul 2015 20:05:04 GMT

    [ https://issues.apache.org/jira/browse/GROOVY-7456?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14610920#comment-14610920
] 

Pascal Schumacher commented on GROOVY-7456:
-------------------------------------------

Sadly it does not, your example from [GROOVY-7373] still fails with "groovy.lang.MissingPropertyException:
No such property: delegate for class: TestClass".

> Builders don't work in Traits
> -----------------------------
>
>                 Key: GROOVY-7456
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7456
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.3
>            Reporter: Graeme Rocher
>            Assignee: C├ędric Champeau
>             Fix For: 2.4.4
>
>
> Traits don't take into account closure delegates, this completely breaks any builder
or dynamic behaviour. The following example:
> {code}
> import groovy.xml.*
> trait MyBuilder {
>     def build2() {
>         def mkp = new MarkupBuilder()
>         
>         mkp.foo {
>             bar()
>         }
>     }
> }
> class Foo implements MyBuilder {
>     def build1() {
>         def mkp = new MarkupBuilder()
>         
>         mkp.foo {
>             bar()
>         }
>     }
> }
> foo = new Foo()
> foo.build1()
> foo.build2()
> {code}
> Fails with:
> {code}
> roovy.lang.MissingMethodException: No signature of method: Foo.bar() is applicable for
argument types: () values: []
> Possible solutions: wait(), any(), wait(long), use([Ljava.lang.Object;), any(groovy.lang.Closure),
is(java.lang.Object)
> 	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:56)
> 	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:51)
> 	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
> 	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:110)
> 	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:114)
> 	at MyBuilder$Trait$Helper$_build2_closure1.doCall(ConsoleScript1:8)
> 	at MyBuilder$Trait$Helper$_build2_closure1.doCall(ConsoleScript1)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:606)
> 	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
> 	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
> 	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:292)
> 	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
> 	at groovy.lang.Closure.call(Closure.java:423)
> 	at groovy.lang.Closure.call(Closure.java:417)
> 	at groovy.util.BuilderSupport.doInvokeMethod(BuilderSupport.java:143)
> 	at groovy.util.BuilderSupport.invokeMethod(BuilderSupport.java:64)
> 	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
> 	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
> 	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:110)
> 	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:122)
> 	at MyBuilder$Trait$Helper.build2(ConsoleScript1:7)
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message