groovy
  1. groovy
  2. GROOVY-2503 MOP 2.0 design inflluencing issues
  3. GROOVY-2635

Can't replace a setProperty method declared in an object with metaclass directives.

    Details

    • Type: Sub-task Sub-task
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.5.4
    • Fix Version/s: None
    • Component/s: groovy-runtime
    • Labels:
      None
    • Number of attachments :
      0

      Description

      The following script:

      class Test {
          void setProperty(String name, value) {
              println "instanceSetProperty"
          }
      
          void myMeth() {
              println 'instanceMyMeth'
          }
      }
      
      Test.metaClass.setProperty = { String name, value ->
         println 'metaSetProperty'
      }
      Test.metaClass.myMeth = { ->
         println 'metaMyMeth'
      }
      Test test = new Test()
      test.a = 'b'
      test.myMeth()
      

      yields:

      instanceSetProperty
      metaMyMeth

      The setProperty method added via the metaclass is ignored.

        Issue Links

          Activity

          Hide
          blackdrag blackdrag added a comment -

          I changed the fix version to 2.0 because 2.0 is thought to implement a MOP redesign and as long as this does not happen it is unlikely that we will find a good work around for this. It is a limitation of the current design

          Show
          blackdrag blackdrag added a comment - I changed the fix version to 2.0 because 2.0 is thought to implement a MOP redesign and as long as this does not happen it is unlikely that we will find a good work around for this. It is a limitation of the current design

            People

            • Assignee:
              Unassigned
              Reporter:
              Hans Dockter
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: