groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] branch master updated: Trivial tweaking DGSM support for native method reference
Date Fri, 28 Jun 2019 14:40:08 GMT
This is an automated email from the ASF dual-hosted git repository.

sunlan 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 c47d014  Trivial tweaking DGSM support for native method reference
c47d014 is described below

commit c47d0144101e7e5ffafcd0177a742b8c54ca948c
Author: Daniel Sun <sunlan@apache.org>
AuthorDate: Fri Jun 28 22:39:53 2019 +0800

    Trivial tweaking DGSM support for native method reference
---
 .../sc/StaticTypesMethodReferenceExpressionWriter.java |  2 +-
 .../groovy/transform/stc/MethodReferenceTest.groovy    | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

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 2a8438d..708ef51 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
@@ -195,7 +195,7 @@ public class StaticTypesMethodReferenceExpressionWriter extends MethodReferenceE
         args.getExpressions().add(0, ConstantExpression.NULL);
 
         return controller.getClassNode().addSyntheticMethod(
-                "dgsm$" + mn.getParameters()[0].getType().getName().replace(".", "_") + "$"
+ mn.getName(),
+                "dgsm$$" + mn.getParameters()[0].getType().getName().replace(".", "$") +
"$$" + mn.getName(),
                 Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_SYNTHETIC,
                 mn.getReturnType(),
                 parameters,
diff --git a/src/test/groovy/transform/stc/MethodReferenceTest.groovy b/src/test/groovy/transform/stc/MethodReferenceTest.groovy
index ac75952..0d6d781 100644
--- a/src/test/groovy/transform/stc/MethodReferenceTest.groovy
+++ b/src/test/groovy/transform/stc/MethodReferenceTest.groovy
@@ -443,4 +443,22 @@ class MethodReferenceTest extends GroovyTestCase {
             p()
         '''
     }
+
+    // class::staticMethod
+    void testFunctionCS_MULTI_DGSM() {
+        assertScript '''
+            import java.util.stream.Collectors
+            
+            @groovy.transform.CompileStatic
+            void p() {
+                def result = [{}, {}, {}].stream().map(Thread::startDaemon).collect(Collectors.toList())
+                assert result.every(e -> e instanceof Thread)
+                
+                result = [{}, {}, {}].stream().map(Thread::startDaemon).collect(Collectors.toList())
+                assert result.every(e -> e instanceof Thread)
+            }
+            
+            p()
+        '''
+    }
 }


Mime
View raw message