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

MetaClassImpl.getAttribute(Class,Object,String,boolean) drops super

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.19, 3.0.4, 2.5.12
    • 2.4.20, 3.0.5, 2.5.13
    • None
    • None

    Description

      ScriptBytecodeAdapter.getFieldOnSuper calls MetaClass#getAttribute(SuperType,thisObject,"fieldName",true).
      MetaClassImpl delegates and drops the super flag in the process.

      class A {
        public x = 'A'
      }
      class B extends A {
        public x = 'B'
      }
      
      def a = new A()
      println a.metaClass.getAttribute(A, a, 'x', false) // prints "A"
      
      def b = new B()
      println b.metaClass.getAttribute(B, b, 'x', false) // prints "B"
      
      println b.metaClass.getAttribute(A, b, 'x', true) // prints "B", but "A" is expected
      println ScriptBytecodeAdapter.getFieldOnSuper(A, b, 'x') // prints "B", but "A" is expected
      

      Attachments

        Activity

          People

            emilles Eric Milles
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: