Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-10188

Different treatment of property expressions in closures from 2.4 to 2.5

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5.14
    • 2.5.15, 4.0.0-beta-1, 3.0.9
    • Compiler
    • None

    Description

      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

       List<Integer> myList = [1,2,3]
       myList.each { Integer -> println Integer.xxx}
      

      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: If you look in the AST browser, after conversion phase we have:

      public java.lang.Object run()  {
          List<Integer> myList = [1, 2, 3] 
          myList.each({ java.lang.Object Integer ->
             this.println( Integer .xxx) 
          })
      }
      

      By end of semantic analysis phase we have:

      public java.lang.Object run()  {
          List<Integer> myList = [1, 2, 3] 
          myList.each({ java.lang.Object Integer ->
              this.println( java.lang.Integer) 
          })
      }
      

       

      Attachments

        Activity

          People

            paulk Paul King
            dariusx Darius Cooper
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: