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
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.5.4
    • Fix Version/s: None
    • Component/s: groovy-runtime
    • Labels:
      None

      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

          Hans Dockter created issue -
          Hide
          Jochen Theodorou 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
          Jochen Theodorou 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
          Jochen Theodorou made changes -
          Field Original Value New Value
          Fix Version/s 2.0 [ 13489 ]
          Fix Version/s 1.5.5 [ 14028 ]
          Jochen Theodorou made changes -
          Link This issue depends upon GROOVY-2503 [ GROOVY-2503 ]
          Jochen Theodorou made changes -
          Issue Type Bug [ 1 ] Sub-task [ 7 ]
          Parent GROOVY-2503 [ 61571 ]
          Jochen Theodorou made changes -
          Fix Version/s 3.0 [ 13489 ]
          Jochen Theodorou made changes -
          Component/s groovy-runtime [ 16250 ]
          Mark Thomas made changes -
          Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
          Mark Thomas made changes -
          Workflow jira [ 12731670 ] Default workflow, editable Closed status [ 12743552 ]
          Mark Thomas made changes -
          Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
          Mark Thomas made changes -
          Workflow jira [ 12969708 ] Default workflow, editable Closed status [ 12977437 ]

            People

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

              Dates

              • Created:
                Updated:

                Development