You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Pavel (JIRA)" <ji...@apache.org> on 2018/04/28 21:25:00 UTC
[jira] [Created] (GROOVY-8563) Documentation methodMissing example
incorrect
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)