You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by ecerulm <gi...@git.apache.org> on 2018/05/03 07:15:09 UTC
[GitHub] groovy pull request #693: Allow methodMissing/propertyMissing to be defined ...
GitHub user ecerulm opened a pull request:
https://github.com/apache/groovy/pull/693
Allow methodMissing/propertyMissing to be defined through category
Resolves GROOVY-3867
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/ecerulm/groovy GROOVY-3867-pq
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/groovy/pull/693.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 #693
----
commit 8d6af73c53d0f0ad8c2e7b72d214ba732b14e8ee
Author: Ruben Laguna <ru...@...>
Date: 2018-05-01T10:07:54Z
Allow methodMissing/propertyMissing to be defined through category
Resolves GROOVY-3867
----
---
[GitHub] groovy pull request #693: Allow methodMissing/propertyMissing to be defined ...
Posted by ecerulm <gi...@git.apache.org>.
Github user ecerulm commented on a diff in the pull request:
https://github.com/apache/groovy/pull/693#discussion_r185943651
--- Diff: src/main/groovy/groovy/lang/MetaClassImpl.java ---
@@ -945,6 +945,15 @@ private Object invokeMissingMethod(Object instance, String methodName, Object[]
onInvokeMethodFoundInHierarchy(method);
return method.invoke(instance, invokeMethodArgs);
}
+
+ // last resort look in the category
+ if (method == null && GroovyCategorySupport.hasCategoryInCurrentThread()) {
+ method = getCategoryMethodMissing(instanceKlazz);
+ if (method != null) {
+ //TODO add onMethodMissingFound(method)
--- End diff --
No, I think I should just remove that TODO. Currently there is no onMethodMissingFound() for the "regular" methodMissing() (not from a category). As far as I understand the on*Found() hooks are only used by the ExpandoMetaClass to store/cache resolved methods, and I guess the missingMethod from a category should not be remembered (it should disappear after the category is no longer in effect).
---
[GitHub] groovy pull request #693: Allow methodMissing/propertyMissing to be defined ...
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/groovy/pull/693
---
[GitHub] groovy pull request #693: Allow methodMissing/propertyMissing to be defined ...
Posted by danielsun1106 <gi...@git.apache.org>.
Github user danielsun1106 commented on a diff in the pull request:
https://github.com/apache/groovy/pull/693#discussion_r185901767
--- Diff: src/main/groovy/groovy/lang/MetaClassImpl.java ---
@@ -945,6 +945,15 @@ private Object invokeMissingMethod(Object instance, String methodName, Object[]
onInvokeMethodFoundInHierarchy(method);
return method.invoke(instance, invokeMethodArgs);
}
+
+ // last resort look in the category
+ if (method == null && GroovyCategorySupport.hasCategoryInCurrentThread()) {
+ method = getCategoryMethodMissing(instanceKlazz);
+ if (method != null) {
+ //TODO add onMethodMissingFound(method)
--- End diff --
I see a `TODO` here. Are you going to refine it later?
---