You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2020/02/12 04:49:15 UTC

[groovy] branch master updated: GROOVY-9387: MissingMethodException: try one more metaClass.invokeMethod (closes #1162)

This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new 3d8c17d  GROOVY-9387: MissingMethodException: try one more metaClass.invokeMethod (closes #1162)
3d8c17d is described below

commit 3d8c17dd1b8269f4151fb4785759b60acaf7952c
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sat Feb 8 12:57:54 2020 -0600

    GROOVY-9387: MissingMethodException: try one more metaClass.invokeMethod (closes #1162)
---
 .../codehaus/groovy/runtime/callsite/PogoMetaClassSite.java   | 11 +++++++++--
 src/test/groovy/bugs/Groovy9387.groovy                        |  5 +----
 2 files changed, 10 insertions(+), 6 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 93eada5..c6f0f78 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.codehaus.groovy.control.CompilerConfiguration
 import org.junit.Test
@@ -60,10 +59,8 @@ final class Groovy9387 {
         '''
     }
 
-    @Test @NotYetImplemented
+    @Test
     void testThisSetProperty() {
-        // currently only broken for classic bytecode (TODO: remove assumeFalse line and this comment once issue is fixed - no harm in having an indy testcase at that point)
-        assumeFalse CompilerConfiguration.DEFAULT.optimizationOptions?.indy
         assertScript SUPPORT_ADAPTER + '''
             class C extends BuilderSupportAdapter {
                 String value = 'abc'