You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2016/10/27 10:53:58 UTC

[jira] [Commented] (GROOVY-7973) Class.this not evaluated correctly within a closure within an inner class

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

ASF GitHub Bot commented on GROOVY-7973:
----------------------------------------

GitHub user paulk-asert opened a pull request:

    https://github.com/apache/groovy/pull/451

    GROOVY-7973: Class.this not evaluated correctly within a closure with…

    …in an inner class

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/paulk-asert/groovy groovy7973

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/groovy/pull/451.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #451
    
----
commit 731d548396d8f641f78c7b87ea8a074eb9646c2b
Author: paulk <pa...@asert.com.au>
Date:   2016-10-27T10:51:22Z

    GROOVY-7973: Class.this not evaluated correctly within a closure within an inner class

----


> Class.this not evaluated correctly within a closure within an inner class
> -------------------------------------------------------------------------
>
>                 Key: GROOVY-7973
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7973
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Paul King
>
> There is an incorrect calculation of a qualified 'this' within a closure within an inner class:
> {code}
> //@groovy.transform.CompileStatic
> class Test {
>   def op1() { this }
>   def op2() { ''.with{ this } }
>   def op3() { new Object() { def inner() { this } } }
>   def op4() { new Object() { def inner() { ''.with{ this } } } }
>   def op5() { new Object() { def inner() { Test.this } } }
>   def op6() { new Object() { def inner() { ''.with{ Test.this } } } }
>   class Inner {
>     def inner1() { this }
>     def inner2() { ''.with { this } }
>     def inner3() { Test.this }
>     def inner4() { ''.with { Test.this } }
>   }
> }
> def t = new Test()
> assert t.op1().class.name == 'Test'
> assert t.op2().class.name == 'Test'
> assert t.op3().inner().class.name == 'Test$1'
> assert t.op4().inner().class.name == 'Test$2'
> assert t.op5().inner().class.name == 'Test'
> assert t.op6().inner().class.name == 'Test$4$_inner_closure1'  // Current
> //assert t.op6().inner().class.name == 'Test'  // Expected
> def inner = new Test.Inner(t)
> assert inner.inner1().class.name == 'Test$Inner'
> assert inner.inner2().class.name == 'Test$Inner'
> assert inner.inner3().class.name == 'Test'
> assert inner.inner4().class.name == 'Test$Inner$_inner4_closure2' // Current
> // assert inner.inner4().class.name == 'Test' // Expected
> {code}



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