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

Compiler does not validate final assignment in constructors

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Information Provided
    • 4.0.12
    • None
    • Compiler
    • None

    Description

      The Groovy compiler does not seem to make any attempt to verify that final fields are assigned during object construction, making possible very simple bugs (I added a property but forgot the "this" assignment) that the Java compiler flags. I'm aware that the richness of Groovy expressiveness may make this difficult, but it's frustrating not to have that safeguard.

      class Bug {
          final Object o // and add an explicit constructor if you like
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            chrylis Christopher Smith
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: