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 2021/08/04 21:16:00 UTC

[jira] [Commented] (GROOVY-10188) Different treatment of closure parameters from 2.4 to 2.5

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

Eric Milles commented on GROOVY-10188:
--------------------------------------

It is this method in {{ResolveVisitor}} that is resolving "Integer.xxx" into just "Integer".  https://github.com/apache/groovy/blob/15cec16df76dccf58d7e35c007c7d985ae6d9f1b/src/main/java/org/codehaus/groovy/control/ResolveVisitor.java#L1011

> Different treatment of closure parameters from 2.4 to 2.5
> ---------------------------------------------------------
>
>                 Key: GROOVY-10188
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10188
>             Project: Groovy
>          Issue Type: Question
>          Components: Compiler
>    Affects Versions: 2.5.14
>            Reporter: Darius Cooper
>            Priority: Major
>
> We noticed a change in behavior moving from Groovy 2.4.x to 2.5.x,
>  and wondering if it was an _expected_ change. It seems to be a difference with the compiler
>  We use *groovy-eclipse-batch*. 
>  This is a contrived example, but based on an issue we had in PROD
> {code:groovy}
>  List<Integer> myList = [1,2,3]
>  myList.each { Integer -> println Integer.xxx}
> {code}
>  With groovy-eclipse-batch  2.4.17-01 (and groovy 2.4.15) we get errors saying:
>  _No such property: xxx for class: java.lang.Integer_
> However, using groovy-eclipse-batch 2.5.14-02 and Groovy 2.5.14, it prints out the full class name of the Integer class
> From [this Slack thread: |https://groovy-community.slack.com/archives/C2NEFCM55/p1627652703003000] If you look in the AST browser, *after conversion phase* we have:
> {code:groovy}
> public java.lang.Object run()  {
>     List<Integer> myList = [1, 2, 3] 
>     myList.each({ java.lang.Object Integer ->
>        this.println( Integer .xxx) 
>     })
> }
> {code}
> By *end of semantic analysis phase* we have:
> {code:groovy}
> public java.lang.Object run()  {
>     List<Integer> myList = [1, 2, 3] 
>     myList.each({ java.lang.Object Integer ->
>         this.println( java.lang.Integer) 
>     })
> }
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)