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

Generated Setter for boolean causes "Repetitive method name/signature..."

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.5.7
    • 1.6.1, 1.5.8, 1.7-beta-1
    • Compiler
    • None
    • Windows XP, JDK 1.6.0_03

    Description

      When I run the following (Groovy 1.5.7):

      class BoolTest {
          boolean success
         
          boolean isSuccess() {
              return success ?: true
          }
         
          static void main(args) {
              def test = new BoolTest()
          }
      }
      

      I get this compilation error:

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed,
      D:\work\temp\BoolTest.groovy: 4: Repetitive method name/signature for method 'boolean isSuccess()' in class 'BoolTest'.
      @ line 4, column 5.
      boolean isSuccess() {
      ^
      D:\work\temp\BoolTest.groovy: -1: Repetitive method name/signature for method 'boolean isSuccess()' in class 'BoolTest'.
      @ line -1, column -1.
      2 errors

      While the following is fine:

      class BoolTest {
          String success
         
          String getSuccess() {
              return success ?: ""
          }
         
          static void main(args) {
              def test = new BoolTest()
          }
      }
      

      Roshan:

      I looked into the code where groovy creates getters and setters for the properties if not already provided by the user and for boolean properties, the check to see if a getter is provided is only using get<PropName>. It should check both get<PropName> and is<PropName> if the type of the property is boolean/Boolean.

      Attachments

        Activity

          People

            roshandawrani Roshan Dawrani
            gyrm Haw-Bin Chai
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: