You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2019/06/28 15:19:11 UTC

[groovy] branch master updated: Correct the priority of DGM when choosing methods

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 56df979  Correct the priority of DGM when choosing methods
56df979 is described below

commit 56df979e34c9e2558a686f9c3ec53d38174c3d60
Author: Daniel Sun <su...@apache.org>
AuthorDate: Fri Jun 28 23:19:06 2019 +0800

    Correct the priority of DGM when choosing methods
---
 .../sc/StaticTypesMethodReferenceExpressionWriter.java   |  2 +-
 src/test/groovy/transform/stc/MethodReferenceTest.groovy | 16 ++++++++++++++++
 2 files changed, 17 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 708ef51..eb45281 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
@@ -362,7 +362,7 @@ public class StaticTypesMethodReferenceExpressionWriter extends MethodReferenceE
         }
 
         if (isExtensionMethod(mn)) {
-            score -= 100;
+            score += 100;
         }
 
         return score;
diff --git a/src/test/groovy/transform/stc/MethodReferenceTest.groovy b/src/test/groovy/transform/stc/MethodReferenceTest.groovy
index 0d6d781..fdc28e7 100644
--- a/src/test/groovy/transform/stc/MethodReferenceTest.groovy
+++ b/src/test/groovy/transform/stc/MethodReferenceTest.groovy
@@ -444,6 +444,22 @@ class MethodReferenceTest extends GroovyTestCase {
         '''
     }
 
+    // class::instanceMethod
+    void testFunctionCI_SHADOW_DGM() {
+        assertScript '''
+            import java.util.stream.Collectors
+            
+            @groovy.transform.CompileStatic
+            void p() {
+                def result = [[a:1], [b:2], [c:3]].stream().map(Object::toString).collect(Collectors.toList())
+                assert 3 == result.size()
+                assert ['[a:1]', '[b:2]', '[c:3]'] == result
+            }
+            
+            p()
+        '''
+    }
+
     // class::staticMethod
     void testFunctionCS_MULTI_DGSM() {
         assertScript '''