You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Jochen Theodorou (JIRA)" <ji...@apache.org> on 2015/10/22 09:38:27 UTC

[jira] [Resolved] (GROOVY-7641) StackOverflow Exception when calling method that has same signature as one that inside Closure.groovy

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

Jochen Theodorou resolved GROOVY-7641.
--------------------------------------
    Resolution: Won't Fix
      Assignee: Jochen Theodorou

The implicit "this" in a Closure is different from the normal implicit one in a class. In a Closure it is subject to the resolving rules of the Closure, which includes the Closure itself for example, thus the overflow. You can fix this easily by writing out the "this" to this.run(). Now "this" will mean the enclosing class instance and call the right method

> StackOverflow Exception when calling method that has same signature as one that inside Closure.groovy
> -----------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-7641
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7641
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-jdk
>         Environment: OSX Yosemite 10.10.5
>            Reporter: Batuhan Bayrakçı
>            Assignee: Jochen Theodorou
>         Attachments: errorlog.txt
>
>
> When i call a method that has same method signature as one inside Closure.groovy, it causes StackOverflow Exception
> I have tried on recent revision of code from github.
> {code:title=ImplClass.groovy|borderStyle=solid}
> class ImplClass {
>     def closureAsMethod = {
>         run()
>     }
>     def method() {
>         run()
>     }
>     def run() {
>         println("run implementation")
>     }
> }
> {code}
> While {{new ImplClass().method()}} call runs as expected, {{new ImplClass().closureAsMethod()}} attempts to call "run" method in Closure.groovy instead of "run" in ImplClass.groovy, then it causes StackOverflow exception. Stack trace is in attachment.
> In {{CallClosureFieldAsMethodTest.groovy}}, comment says that _"Check that we can call a closure defined as a field as if it were a normal method"_. So, it is normal to wait same behavior as normal method.



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