[ 
https://issues.apache.org/jira/browse/GROOVY-7938?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Paul King resolved GROOVY-7938.
-------------------------------
       Resolution: Fixed
    Fix Version/s: 2.4.8

Proposed PR merged.

> inconsistent access of methods in outer class
> ---------------------------------------------
>
>                 Key: GROOVY-7938
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7938
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.7
>            Reporter: Paul King
>            Assignee: Paul King
>             Fix For: 2.4.8
>
>
> Groovy handles access to outer instance and static methods from inner classes 
> but not nested (i.e. static) ones. The following code illustrates the problem:
> {code}class Outer {
>     static Integer fooCount = 0
>     Integer barCount = 0
>     static void incFoo() { fooCount++ }
>     void incBar() { barCount++ }
>     static class Nested {
>         static void nestedIncFoo() { incFoo() }
>     }
>     Inner innerFactory() { new Inner() }
>     class Inner { }
> }
> Outer.incFoo()
> //Outer.Nested.nestedIncFoo() // => MME
> assert Outer.fooCount == 1 // but should be 2 if no MME
> new Outer().with {
>     incBar()
>     incFoo()
>     innerFactory().with {
>         incBar()
>         incFoo()
>     }
>     assert barCount == 2
>     assert fooCount == 3 // but should be 4 if no MME
> }
> {code}
> After the fix, the following is expected to work:
> {code}
> class Outer {
>     static Integer fooCount = 0
>     Integer barCount = 0
>     static void incFoo() { fooCount++ }
>     void incBar() { barCount++ }
>     static class Nested {
>         static void nestedIncFoo() { incFoo() }
>     }
>     Inner innerFactory() { new Inner() }
>     class Inner { }
> }
> Outer.incFoo()
> Outer.Nested.nestedIncFoo()
> assert Outer.fooCount == 2
> new Outer().with {
>     incBar()
>     incFoo()
>     innerFactory().with {
>         incBar()
>         incFoo()
>     }
>     assert barCount == 2
>     assert fooCount == 4
> }
> {code}
> Basically the commented out line should work.



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

Reply via email to