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

@EqualsAndHashCode can't recognize final field

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5.3
    • 3.0.0-beta-1, 2.5.7
    • ast builder
    • None
    • 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

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment