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

@EqualsAndHashCode can't recognize final field

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.5.3
    • Fix Version/s: 3.0.0-beta-1, 2.5.7
    • Component/s: ast builder
    • Labels:
      None
    • Environment:
      Groovy Version: 2.5.3 JVM: 11.0.2 Vendor: Oracle Corporation OS: Mac OS X

      Description

      import groovy.transform.EqualsAndHashCode
      
      @EqualsAndHashCode(includes = ["name"])
      class Test {
          private final String name
          Test(String name) {
              this.name = name
          }
      
          String getName() {
              return name
          }
      }
      

      Groovy 2.5.3 complains: 

      /Users/zhb/Projects/tmp/Main.groovy: 3: Error during @EqualsAndHashCode processing: 'includes' property 'name' does not exist.
      @ line 3, column 1.
      @EqualsAndHashCode(includes = ["name"])
      ^
      
      1 error
      

      But Groovy 2.4.16 works fine.

        Attachments

          Activity

            People

            • Assignee:
              paulk Paul King
              Reporter:
              blindpirate zhb
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: