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

Final variable analysis broken within closure fields

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5.x
    • 2.5.0-beta-3
    • Compiler
    • None

    Description

      The following code compiles and runs successfully in 2.4.8 but fails in 2.5 snapshots:

      class Foo {
          public Closure bar = {
              final RANKINGS = ["year": 0, "month": 10]
          }
      }
      
      new Foo().bar()
      

      Error message is:

      1 compilation error:
      The variable [RANKINGS] is declared final but is reassigned
      . At [3:9]  at line: 3, column: 9
      

      Attachments

        Issue Links

          Activity

            People

              paulk Paul King
              paulk Paul King
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: