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

Errors with static attribute expression

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.3
    • 2.1.4
    • None
    • None

    Description

      The following code triggers an InvalidClassChangeError:

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

      While this one will trigger an internal compiler error

      class A {
         static protected int x
         public static void reset() { this.@x = 2 }
      }
      
      BUG! exception in phase 'class generation' in source unit 'ConsoleScript1' Error while popping argument from operand stack tracker in class A method void reset().

      Attachments

        Issue Links

          Activity

            People

              melix Cédric Champeau
              melix Cédric Champeau
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: