groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [groovy] 18/20: Improve the robustness
Date Mon, 08 Apr 2019 12:59:10 GMT
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

commit df5c8c6f8b915500a5a2ea3897eb348ebdb38d58
Author: Daniel Sun <sunlan@apache.org>
AuthorDate: Wed Mar 27 00:36:33 2019 +0800

    Improve the robustness
---
 .../groovy/classgen/asm/sc/StaticTypesLambdaWriter.java       | 11 ++++++++---
 .../asm/sc/StaticTypesMethodReferenceExpressionWriter.java    | 11 ++++++++---
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesLambdaWriter.java
b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesLambdaWriter.java
index 1a3c1c8..af3e631 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesLambdaWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesLambdaWriter.java
@@ -86,10 +86,15 @@ public class StaticTypesLambdaWriter extends LambdaWriter implements AbstractFun
     @Override
     public void writeLambda(LambdaExpression expression) {
         ClassNode functionalInterfaceType = getFunctionalInterfaceType(expression);
-        ClassNode redirect = functionalInterfaceType.redirect();
+        if (null == functionalInterfaceType) {
+            // if the parameter type failed to be inferred, generate the default bytecode,
which is actually a closure
+            super.writeLambda(expression);
+            return;
+        }
 
-        if (null == functionalInterfaceType || !ClassHelper.isFunctionalInterface(redirect))
{
-            // if the parameter type is not real FunctionInterface or failed to be inferred,
generate the default bytecode, which is actually a closure
+        ClassNode redirect = functionalInterfaceType.redirect();
+        if (!ClassHelper.isFunctionalInterface(redirect)) {
+            // if the parameter type is not real FunctionalInterface, generate the default
bytecode, which is actually a closure
             super.writeLambda(expression);
             return;
         }
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java
b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java
index f41a37b..7e1275d 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java
@@ -64,10 +64,15 @@ public class StaticTypesMethodReferenceExpressionWriter extends MethodReferenceE
     @Override
     public void writeMethodReferenceExpression(MethodReferenceExpression methodReferenceExpression)
{
         ClassNode functionalInterfaceType = getFunctionalInterfaceType(methodReferenceExpression);
-        ClassNode redirect = functionalInterfaceType.redirect();
+        if (null == functionalInterfaceType) {
+            // if the parameter type failed to be inferred, generate the default bytecode,
which is actually a method closure
+            super.writeMethodReferenceExpression(methodReferenceExpression);
+            return;
+        }
 
-        if (null == functionalInterfaceType || !ClassHelper.isFunctionalInterface(redirect))
{
-            // if the parameter type is not real FunctionInterface or failed to be inferred,
generate the default bytecode, which is actually a method closure
+        ClassNode redirect = functionalInterfaceType.redirect();
+        if (!ClassHelper.isFunctionalInterface(redirect)) {
+            // if the parameter type is not real FunctionalInterface, generate the default
bytecode, which is actually a method closure
             super.writeMethodReferenceExpression(methodReferenceExpression);
             return;
         }


Mime
View raw message