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

defining a field and a property of the same name

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.6, 1.6-beta-1
    • Fix Version/s: 1.5.7, 1.6-beta-2
    • Component/s: None
    • Labels:
      None

      Description

      class A {
        private foo
        def foo
      }
      

      In this code we produce a field named foo, a private one... and a property foo with bthe same name. It seems the compiler isn't able to handle this case. The compiler will create yet another field foo and a later step will complain about it, so the user gets the message that the field is declared twice. Now I see two solutions to this.. first one is that we let the property use another field, but then this.foo for example would not access the property field. The other solution would be to fix the handling not to generate a field of this name, but reuse the existing one instead. The third option would be to not to allow this... but being able to change the visibiblity of the field, for example to protected, could be interesting to have as well. So I suggest to go with optiontwo and fix it.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                blackdrag Jochen Theodorou
                Reporter:
                blackdrag Jochen Theodorou
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: