You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2020/12/21 04:16:19 UTC

[groovy] branch GROOVY-9860 created (now cf407fc)

This is an automated email from the ASF dual-hosted git repository.

emilles pushed a change to branch GROOVY-9860
in repository https://gitbox.apache.org/repos/asf/groovy.git.


      at cf407fc  GROOVY-9860: makeRawType should reduce generic placeholder to bound type

This branch includes the following new commits:

     new cf407fc  GROOVY-9860: makeRawType should reduce generic placeholder to bound type

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[groovy] 01/01: GROOVY-9860: makeRawType should reduce generic placeholder to bound type

Posted by em...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch GROOVY-9860
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit cf407fc17f5bcd48d5e6bde52a0cde6aa5395d27
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sun Dec 20 22:16:04 2020 -0600

    GROOVY-9860: makeRawType should reduce generic placeholder to bound type
    
    Tuple2 constructor parameters are placeholders and should reduce to
    Object for argument matching
---
 .../groovy/transform/stc/StaticTypeCheckingSupport.java     |  2 +-
 src/test/groovy/transform/stc/GenericsSTCTest.groovy        | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
index 16008b7..2b404d8 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java
@@ -1127,7 +1127,7 @@ public abstract class StaticTypeCheckingSupport {
             String name = param.getType().getUnresolvedName();
             Optional<GenericsType> value = genericsPlaceholderAndTypeMap.entrySet().stream()
                 .filter(e -> e.getKey().getName().equals(name)).findFirst().map(Map.Entry::getValue);
-            ClassNode type = value.map(GenericsType::getType).orElseGet(() -> makeRawType(param.getType()));
+            ClassNode type = value.map(gt -> !gt.isPlaceholder() ? gt.getType() : makeRawType(gt.getType())).orElseGet(() -> makeRawType(param.getType()));
 
             return new Parameter(type, param.getName());
         }).toArray(Parameter[]::new);
diff --git a/src/test/groovy/transform/stc/GenericsSTCTest.groovy b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
index 964e075..9f32908 100644
--- a/src/test/groovy/transform/stc/GenericsSTCTest.groovy
+++ b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
@@ -427,6 +427,19 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
         '''
     }
 
+    // GROOVY-9860
+    void testGenericTypeArgumentInCtorCall() {
+        assertScript '''
+            def <T> void test() {
+                def bind = { T a, T b ->
+                    new Tuple2<T, T>(a, b)
+                }
+                assert bind('foo', 'bar').toString() == '[foo, bar]'
+            }
+            test()
+        '''
+    }
+
     void testReturnAnntationClass() {
         assertScript '''
             import java.lang.annotation.Documented