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

Static compiler calls setter even with attribute notation

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: 2.0.1
    • Component/s: Static compilation
    • Labels:
      None

      Description

      If compiled with @CompileStatic, in the following example, we use the attribute notation, so the static compiler should perform a direct field access. However, it calls the setter:

      class A {
          boolean setterCalled = false
      
          protected int x
          public void setX(int a) {
              setterCalled = true
              x = a
          }
      }
      class B extends A {
          void m() {
              this.@x = 2
          }
      }
      B b = new B()
      b.m()
      assert b.isSetterCalled() == false
      

        Attachments

          Activity

            People

            • Assignee:
              melix Cédric Champeau
              Reporter:
              melix Cédric Champeau
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: