You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2022/02/26 00:50:00 UTC

[jira] [Assigned] (GROOVY-10514) Class method is not called anymore from inside closure

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

Eric Milles reassigned GROOVY-10514:
------------------------------------

    Assignee: Eric Milles

> Class method is not called anymore from inside closure
> ------------------------------------------------------
>
>                 Key: GROOVY-10514
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10514
>             Project: Groovy
>          Issue Type: Bug
>          Components: syntax
>    Affects Versions: 4.0.0
>            Reporter: Lóránt Pintér
>            Assignee: Eric Milles
>            Priority: Major
>
> This code works with Groovy 3.0.9, but doesn't work with 4.0.0:
> {code:language=groovy}
> class Lajos {
>     static void main(String[] args) {
>         FileTreeBuilder builder = new FileTreeBuilder()
>         builder {
>             hello("world")
>         }
>     }
>     static void hello(String param) {
>         println "Hello $param!"
>     }
> }
> {code}
> Using 3.0.9 the expected result is printed:
> {code}
> $ ../groovy-3.0.9/bin/groovy script.groovy
> Hello world!
> $ ls -l
> total 8
> -rw-r--r--  1 lptr  staff  249 Feb 26 00:45 script.groovy
> {code}
> Using 4.0.0 instead of calling {{hello()}} the {{methodMissing()}} method is called on {{FileTreeBuilder}} and a file is created.
> {code}
> $ ../groovy-4.0.0/bin/groovy script.groovy
> $ ls -l
> total 16
> -rw-r--r--  1 lptr  staff    5 Feb 26 00:53 hello
> -rw-r--r--  1 lptr  staff  249 Feb 26 00:45 script.groovy
> $ cat hello
> world
> {code}
> Same thing happens when {{hello()}} is called from an instance method, and even if {{hello()}} itself is non-static.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)