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

Jochen Theodorou edited comment on GROOVY-7678 at 11/17/15 6:21 PM:
--------------------------------------------------------------------

{{with(Closure)}} sets the strategy to {{DELEGATE_FIRST}}, so the default 
strategy is no used here. So I don't see a bug here


was (Author: blackdrag):
{{with(Closure)} sets the strategy to {{DELEGATE_FIRST}}, so the default 
strategy is no used here. So I don't see a bug here

> @DelegatesTo nested closures owner
> ----------------------------------
>
>                 Key: GROOVY-7678
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7678
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>            Reporter: Daniil Ovchinnikov
>
> Consider the following snippet
> {code:java}
> class X {
>     def method() { "X" }
>     def anotherMethod(@DelegatesTo(Y) Closure c) { new Y().with(c) }
> }
> class Y {
>     def method() { "Y" }
> }
> def doX(@DelegatesTo(X) Closure c) { new X().with(c) }
> doX {
>     anotherMethod {
>         println owner.method()      // X (correct)
>         println delegate.method()   // Y (correct)
>         println method()            // Y (?)
>     }
> }
> {code}
> Last {{method()}} call should return {{"X"}} because default strategy is 
> {{OWNER_FIRST}} and the owner itself delegates to the {{X}} instance.



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

Reply via email to