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 2021/03/05 20:55:01 UTC

[groovy] branch GROOVY-9968 created (now 9e078f6)

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

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


      at 9e078f6  GROOVY-9968: STC ClosureParams: for "T -> Type" use Type not Object

This branch includes the following new commits:

     new 9e078f6  GROOVY-9968: STC ClosureParams: for "T -> Type" use Type not Object

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-9968: STC ClosureParams: for "T -> Type" use Type not Object

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

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

commit 9e078f64602b6a0ae547d8a56b4cb52ad22640e7
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Fri Mar 5 14:54:44 2021 -0600

    GROOVY-9968: STC ClosureParams: for "T -> Type" use Type not Object
---
 .../groovy/transform/stc/StaticTypeCheckingVisitor.java |  2 +-
 .../stc/ClosureParamTypeInferenceSTCTest.groovy         | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index 1ef88a0..a620193 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -3117,7 +3117,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
         // TODO: Merge with StaticTypeCheckingSupport#getCombinedBoundType(GenericsType)?
         ClassNode value = genericsType.getType();
         if (genericsType.isPlaceholder()) {
-            value = OBJECT_TYPE;
+            value = value.isRedirectNode() ? value.redirect() : OBJECT_TYPE;
         }
         ClassNode lowerBound = genericsType.getLowerBound();
         if (lowerBound != null) {
diff --git a/src/test/groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy b/src/test/groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy
index 87416a2..bc0ac8a 100644
--- a/src/test/groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy
+++ b/src/test/groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy
@@ -1480,4 +1480,21 @@ method()
             new B()
         '''
     }
+
+    void testGroovy9968() {
+        assertScript '''
+            import groovy.transform.*
+            @Canonical class Pogo { String prop }
+            @Canonical class Type<T extends Pogo> implements Iterable<T> {
+                Iterator<T> iterator() {
+                    list.iterator()
+                }
+                List<T> list
+            }
+
+            def iterable = new Type([new Pogo('x'), new Pogo('y'), new Pogo('z')])
+            assert iterable.collect { Pogo p -> p.prop } == ['x', 'y', 'z']
+            assert iterable.collect { it.prop } == ['x', 'y', 'z']
+        '''
+    }
 }