You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2020/02/08 18:58:12 UTC
[groovy] 01/01: GROOVY-9387: MissingMethodException: try one more
metaClass.invokeMethod
This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch GROOVY-9387
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 7800d5f4947e6d8ef6f3cccc413d3fc5a628a660
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sat Feb 8 12:57:54 2020 -0600
GROOVY-9387: MissingMethodException: try one more metaClass.invokeMethod
---
.../codehaus/groovy/runtime/callsite/PogoMetaClassSite.java | 11 +++++++++--
src/test/groovy/bugs/Groovy9387.groovy | 3 +--
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/runtime/callsite/PogoMetaClassSite.java b/src/main/java/org/codehaus/groovy/runtime/callsite/PogoMetaClassSite.java
index 8c172fb..096d038 100644
--- a/src/main/java/org/codehaus/groovy/runtime/callsite/PogoMetaClassSite.java
+++ b/src/main/java/org/codehaus/groovy/runtime/callsite/PogoMetaClassSite.java
@@ -63,8 +63,15 @@ public class PogoMetaClassSite extends MetaClassSite {
if (e instanceof MissingMethodExecutionFailed) {
throw (MissingMethodException) e.getCause();
} else if (receiver.getClass() == e.getType() && e.getMethod().equals(name)) {
- // in case there's nothing else, invoke the object's own invokeMethod()
- return receiver.invokeMethod(name, args);
+ // in case there's nothing else, invoke the receiver's own invokeMethod()
+ try {
+ return receiver.invokeMethod(name, args);
+ } catch (MissingMethodException mme) {
+ if (mme instanceof MissingMethodExecutionFailed)
+ throw (MissingMethodException) mme.getCause();
+ // GROOVY-9387: in rare cases, this form still works
+ return metaClass.invokeMethod(receiver, name, args);
+ }
} else {
throw e;
}
diff --git a/src/test/groovy/bugs/Groovy9387.groovy b/src/test/groovy/bugs/Groovy9387.groovy
index ef80987..1a8e775 100644
--- a/src/test/groovy/bugs/Groovy9387.groovy
+++ b/src/test/groovy/bugs/Groovy9387.groovy
@@ -18,7 +18,6 @@
*/
package groovy.bugs
-import groovy.test.NotYetImplemented
import groovy.transform.CompileStatic
import org.junit.Test
@@ -58,7 +57,7 @@ final class Groovy9387 {
'''
}
- @Test @NotYetImplemented
+ @Test
void testThisSetProperty() {
assertScript SUPPORT_ADAPTER + '''
class C extends BuilderSupportAdapter {