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

Groovy should not generate both `getFlag` and `isFlag` for a Boolean field.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Duplicate
    • 3.0.9
    • 4.0.0-beta-1
    • Compiler
    • None

    Description

      Before, Groovy 2 only generates one getter for a Boolean field.

      But now Groovy 3 generates two, it breaks some ORM frameworks (ex: MyBatis, it can not decide which getter to be used) and breaks JSON output.

      And the meaning of `isFlag` is wrong, it should not return `Boolean` in my mind.

       

      @CompileStatic
      class Foo {
      
          Boolean flag
      
          static void main(String[] args) {
              Foo foo = new Foo()
              println(foo.getFlag())
              println(foo.isFlag())  // should not generate the `isFlag` getter
          }
      }
       

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              wxiaoguang Xiaoguang Wang
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: