groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] branch GROOVY_3_0_X updated: Add the missing checks for lambda to align with closure
Date Thu, 12 Dec 2019 04:10:17 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/GROOVY_3_0_X by this push:
     new 028a31a  Add the missing checks for lambda to align with closure
028a31a is described below

commit 028a31a80bd628c64cbdc5b0b4261134a4afffd7
Author: Daniel Sun <sunlan@apache.org>
AuthorDate: Thu Dec 12 12:04:52 2019 +0800

    Add the missing checks for lambda to align with closure
    
    (cherry picked from commit 2bc350476ea84b1549cadfb337707612160c82c5)
---
 src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java       | 2 +-
 src/main/java/org/codehaus/groovy/classgen/asm/InvocationWriter.java    | 2 +-
 .../src/main/groovy/groovy/console/ui/ScriptToTreeNodeAdapter.groovy    | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java b/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java
index 8123d66..18038cf 100644
--- a/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java
+++ b/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java
@@ -940,7 +940,7 @@ public class AsmClassGenerator extends ClassGenerator {
                 iterType = iterType.getOuterClass();
                 if (thisField == null) {
                     // closure within inner class
-                    while (iterType.isDerivedFrom(ClassHelper.CLOSURE_TYPE) && iterType.implementsInterface(ClassHelper.GENERATED_CLOSURE_Type))
{
+                    while (iterType.isDerivedFrom(ClassHelper.CLOSURE_TYPE) && iterType.implementsAnyInterfaces(ClassHelper.GENERATED_CLOSURE_Type,
ClassHelper.GENERATED_LAMBDA_TYPE)) {
                         // GROOVY-8881: cater for closures within closures - getThisObject
is already outer class of all closures
                         iterType = iterType.getOuterClass();
                     }
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/InvocationWriter.java b/src/main/java/org/codehaus/groovy/classgen/asm/InvocationWriter.java
index 71fef6c..2927d8a 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/InvocationWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/InvocationWriter.java
@@ -100,7 +100,7 @@ public class InvocationWriter {
     public void makeCall(final Expression origin, final Expression receiver, final Expression
message, final Expression arguments, final MethodCallerMultiAdapter adapter, boolean safe,
final boolean spreadSafe, boolean implicitThis) {
         ClassNode sender = controller.getClassNode();
         if (AsmClassGenerator.isSuperExpression(receiver) || (AsmClassGenerator.isThisExpression(receiver)
&& !implicitThis)) {
-            while (sender.isDerivedFrom(ClassHelper.CLOSURE_TYPE) && sender.implementsInterface(ClassHelper.GENERATED_CLOSURE_Type))
{
+            while (sender.isDerivedFrom(ClassHelper.CLOSURE_TYPE) && sender.implementsAnyInterfaces(ClassHelper.GENERATED_CLOSURE_Type,
ClassHelper.GENERATED_LAMBDA_TYPE)) {
                 sender = sender.getOuterClass();
             }
             if (AsmClassGenerator.isSuperExpression(receiver)) {
diff --git a/subprojects/groovy-console/src/main/groovy/groovy/console/ui/ScriptToTreeNodeAdapter.groovy
b/subprojects/groovy-console/src/main/groovy/groovy/console/ui/ScriptToTreeNodeAdapter.groovy
index c184a5d..d9eed68 100644
--- a/subprojects/groovy-console/src/main/groovy/groovy/console/ui/ScriptToTreeNodeAdapter.groovy
+++ b/subprojects/groovy-console/src/main/groovy/groovy/console/ui/ScriptToTreeNodeAdapter.groovy
@@ -336,7 +336,7 @@ class TreeNodeBuildingNodeOperation extends PrimaryClassNodeOperation
{
 
         def innerClassNodes = compileUnit.generatedInnerClasses.values().sort { it.name }
         innerClassNodes.each { InnerClassNode innerClassNode ->
-            if (!innerClassNode.implementsInterface(ClassHelper.GENERATED_CLOSURE_Type) &&
!innerClassNode.implementsInterface(ClassHelper.GENERATED_LAMBDA_TYPE)) return
+            if (!innerClassNode.implementsAnyInterfaces(ClassHelper.GENERATED_CLOSURE_Type,
ClassHelper.GENERATED_LAMBDA_TYPE)) return
             if (innerClassNode.outerMostClass != classNode) return
 
             def child = adapter.make(innerClassNode)


Mime
View raw message