groovy
  1. groovy
  2. GROOVY-3370

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

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.7
    • Fix Version/s: 1.6.1, 1.5.8, 1.7-beta-1
    • Component/s: Compiler
    • Labels:
      None
    • Environment:
      Windows XP, JDK 1.6.0_03
    • Number of attachments :
      0

      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.

        Activity

        Hide
        Roshan Dawrani added a comment -

        Fixed on 1.5.8, 1.6.1 and 1.7-beta-1 branches.

        For a boolean property p, if getP() is not provided, compiler also looks for isP() now before creating a getter itself.

        Show
        Roshan Dawrani added a comment - Fixed on 1.5.8, 1.6.1 and 1.7-beta-1 branches. For a boolean property p, if getP() is not provided, compiler also looks for isP() now before creating a getter itself.

          People

          • Assignee:
            Roshan Dawrani
            Reporter:
            Haw-Bin Chai
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: