groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pavel (JIRA)" <j...@apache.org>
Subject [jira] [Created] (GROOVY-8563) Documentation methodMissing example incorrect
Date Sat, 28 Apr 2018 21:25:00 GMT
Pavel created GROOVY-8563:
-----------------------------

             Summary: Documentation methodMissing example incorrect
                 Key: GROOVY-8563
                 URL: https://issues.apache.org/jira/browse/GROOVY-8563
             Project: Groovy
          Issue Type: Bug
            Reporter: Pavel


[Doc|http://docs.groovy-lang.org/next/html/documentation/core-metaprogramming.html#_methodmissing]
provide example:
{code}
class GORM {

   def dynamicMethods = [...] // an array of dynamic methods that use regex

   def methodMissing(String name, args) {
       def method = dynamicMethods.find { it.match(name) }
       if(method) {
          GORM.metaClass."$name" = { Object[] varArgs ->
             method.invoke(delegate, name, varArgs)
          }
          return method.invoke(delegate,name, args)
       }
       else throw new MissingMethodException(name, delegate, args)
   }
}
{code}
Which reasonable leads to exception:
{noformat}groovy.lang.MissingPropertyException: No such property: delegate for class: ru.taskdata.EgronReader{noformat}
Instead of second 
{code}
method.invoke(delegate, name, varArgs)
{code}
Should be something like:
{code}
return method.invoke(this, args)
{code}

If you wish I could provide pull request. On what repository it should be made?



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message