[jira] [Commented] (GROOVY-7938) inconsistent access of methods in outer class

2016-09-18 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on GROOVY-7938:


Github user asfgit closed the pull request at:

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


> 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
>
> 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)


[jira] [Commented] (GROOVY-7938) inconsistent access of methods in outer class

2016-09-15 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on GROOVY-7938:


GitHub user paulk-asert opened a pull request:

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

GROOVY-7938: inconsistent access of methods in outer class



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

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

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

https://github.com/apache/groovy/pull/421.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 #421


commit 46d81cc6ffb4aa0b625511d6b7c84c97ebe1c627
Author: paulk 
Date:   2016-09-15T09:01:27Z

GROOVY-7938: inconsistent access of methods in outer class




> 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
>
> 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)