Groovy
  1. Groovy
  2. GROOVY-7723

propertyMissing(String,Object) called for missing getter

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.4.0
    • Fix Version/s: 2.4.7
    • Component/s: None
    • Labels:
      None
    • Environment:
      Tested with Groovy 1.8.0, 2.1.0, 2.2.2, and 2.4.0.

      Description

      GROOVY-2098 says that propertyMissing(String) is for getters, while propertyMissing(String,Object) is for setters.

      But as the code snippet below shows, when propertyMissing(String) is missing, missing getters are handled by propertyMissing(String,Object):

      class Sample {
      
          /**
          def propertyMissing(String name) {
              return "propertyMissing(String)"
          }
          **/
      
          def propertyMissing(String name, value) {
              return "propertyMissing(String,Object)"
          }
      }
      
      println new Sample().missing // Prints `propertyMissing(String,Object)`
      

      Is this a bug?

        Issue Links

          Activity

          Hide
          John Wagenleitner added a comment -

          Looks like commit 97a45dfb3e3c5212c36 introduced this change. The original code would not have delegated to the setter method. I don't think the intent of the commit was to change the behavior but resulted inadvertently due to the refactoring.

          Show
          John Wagenleitner added a comment - Looks like commit 97a45dfb3e3c5212c36 introduced this change. The original code would not have delegated to the setter method. I don't think the intent of the commit was to change the behavior but resulted inadvertently due to the refactoring.
          Hide
          ASF GitHub Bot added a comment -

          GitHub user jwagenleitner opened a pull request:

          https://github.com/apache/groovy/pull/307

          GROOVY-7723 - propertyMissing(String,Object) called for missing getter

          Looks like commit 97a45dfb3e3c5212c36 introduced [this change] (https://github.com/apache/groovy/commit/97a45dfb3e3c5212c3610cd90fe1e7434614b260#diff-c1354c0d7df171ad8cafcb3d1bf63857L535). The original code would not have delegated to the setter method. I don't think the intent of the commit was to change the behavior but resulted inadvertently due to the refactoring.

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/jwagenleitner/groovy GROOVY-7723

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/groovy/pull/307.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #307


          commit 930c41d10d41cc9923db90afec53357e15b1d822
          Author: John Wagenleitner <jwagenleitner@apache.org>
          Date: 2016-04-09T09:56:08Z

          GROOVY-7723 - propertyMissing(String,Object) called for missing getter


          Show
          ASF GitHub Bot added a comment - GitHub user jwagenleitner opened a pull request: https://github.com/apache/groovy/pull/307 GROOVY-7723 - propertyMissing(String,Object) called for missing getter Looks like commit 97a45dfb3e3c5212c36 introduced [this change] ( https://github.com/apache/groovy/commit/97a45dfb3e3c5212c3610cd90fe1e7434614b260#diff-c1354c0d7df171ad8cafcb3d1bf63857L535 ). The original code would not have delegated to the setter method. I don't think the intent of the commit was to change the behavior but resulted inadvertently due to the refactoring. You can merge this pull request into a Git repository by running: $ git pull https://github.com/jwagenleitner/groovy GROOVY-7723 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/groovy/pull/307.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #307 commit 930c41d10d41cc9923db90afec53357e15b1d822 Author: John Wagenleitner <jwagenleitner@apache.org> Date: 2016-04-09T09:56:08Z GROOVY-7723 - propertyMissing(String,Object) called for missing getter
          Hide
          ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/groovy/pull/307

          Show
          ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/groovy/pull/307
          Hide
          John Wagenleitner added a comment -

          Thanks for reporting the issue.

          Show
          John Wagenleitner added a comment - Thanks for reporting the issue.

            People

            • Assignee:
              John Wagenleitner
              Reporter:
              Yih Tsern
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development