groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject groovy git commit: Trivial refactoring: extract method
Date Fri, 12 Jan 2018 09:58:00 GMT
Repository: groovy
Updated Branches:
  refs/heads/native-lambda b0aaa1ef9 -> 8096d278f


Trivial refactoring: extract method


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/8096d278
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/8096d278
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/8096d278

Branch: refs/heads/native-lambda
Commit: 8096d278f09343b8acd9d68edf521e03b28b4062
Parents: b0aaa1e
Author: sunlan <sunlan@apache.org>
Authored: Fri Jan 12 17:57:54 2018 +0800
Committer: sunlan <sunlan@apache.org>
Committed: Fri Jan 12 17:57:54 2018 +0800

----------------------------------------------------------------------
 .../groovy/classgen/asm/sc/StaticTypesLambdaWriter.java        | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/8096d278/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesLambdaWriter.java
----------------------------------------------------------------------
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 29c0e40..9681ecd 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
@@ -80,7 +80,7 @@ public class StaticTypesLambdaWriter extends LambdaWriter {
                         .filter(MethodNode::isAbstract)
                         .collect(Collectors.toList());
 
-        if (abstractMethodNodeList.size() != 1) {
+        if (!(isFunctionInterfaceAnnotationAttached(parameterType) && abstractMethodNodeList.size()
== 1)) {
             super.writeClosure(expression);
             return;
         }
@@ -136,6 +136,10 @@ public class StaticTypesLambdaWriter extends LambdaWriter {
         );
     }
 
+    private boolean isFunctionInterfaceAnnotationAttached(ClassNode parameterType) {
+        return !parameterType.redirect().getAnnotations(ClassHelper.makeCached(FunctionalInterface.class)).isEmpty();
+    }
+
     public ClassNode getOrAddLambdaClass(LambdaExpression expression, int mods, MethodNode
abstractMethodNode) {
         ClassNode lambdaClass = lambdaClassMap.get(expression);
         if (lambdaClass == null) {


Mime
View raw message