groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] 03/04: Minor refactoring: remove redundant checks for closure type
Date Fri, 13 Dec 2019 06:04:52 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

commit b09f9c62ad6246a646d5c20cf2b80219ed1211c0
Author: Daniel.Sun <realbluesun@hotmail.com>
AuthorDate: Fri Dec 13 12:01:33 2019 +0800

    Minor refactoring: remove redundant checks for closure type
---
 src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java    | 2 +-
 src/main/java/org/codehaus/groovy/classgen/asm/InvocationWriter.java | 2 +-
 src/main/java/org/codehaus/groovy/classgen/asm/WriterController.java | 1 -
 3 files changed, 2 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 428436c..2f73345 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) && ClassHelper.isGeneratedFunction(iterType))
{
+                    while (ClassHelper.isGeneratedFunction(iterType)) {
                         // 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 8cd5780..221361b 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) && ClassHelper.isGeneratedFunction(sender))
{
+            while (ClassHelper.isGeneratedFunction(sender)) {
                 sender = sender.getOuterClass();
             }
             if (AsmClassGenerator.isSuperExpression(receiver)) {
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/WriterController.java b/src/main/java/org/codehaus/groovy/classgen/asm/WriterController.java
index 6e21864..1db4a89 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/WriterController.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/WriterController.java
@@ -284,7 +284,6 @@ public class WriterController {
 
     public boolean isInClosure() {
         return classNode.getOuterClass() != null
-                && classNode.getSuperClass().equals(ClassHelper.CLOSURE_TYPE)
                 && ClassHelper.isGeneratedFunction(classNode);
     }
 


Mime
View raw message