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

Property not stored via EMC

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.1-rc-2
    • 1.6-rc-2
    • groovy-jdk
    • None
    • Mac OS X 10.4; JDK 1.5; Groovy 1.1-RC-2

    Description

      See http://www.nabble.com/EMC-and-a-property-tf4956215.html

      I have two classes A and B. A is enhanced with meta magic (EMC): a property and a method which should work on this property. B calls the meta method from A, though the property will not change whatever I try. Here's the code:

      ExpandoMetaClass.enableGlobally()

      class A {}

      A.metaClass.status = 'empty'
      A.metaClass.change =

      { println "status from A changed to: $it" status += it }

      class B {
      def getStatus() {
      def a = new A();
      a.change('filled')
      println "status from A through B is: ${a.status}"
      }
      }

      new B().status

      The output is:

      status from A changed to: filled
      status from A through B is: empty

      What I expect in the last line is a 'filled' instead of an 'empty'.

      Attachments

        Activity

          People

            graemerocher Graeme Rocher
            berndschiffer Bernd Schiffer
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: