You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by jw...@apache.org on 2018/05/27 20:39:45 UTC

groovy git commit: GROOVY-8610: STC NPE using DGM collect on Iterator (closes #729)

Repository: groovy
Updated Branches:
  refs/heads/master a44445510 -> 72e530db3


GROOVY-8610: STC NPE using DGM collect on Iterator (closes #729)


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

Branch: refs/heads/master
Commit: 72e530db3bb87644cc989039c31381e7f6ab68dc
Parents: a444455
Author: John Wagenleitner <jw...@apache.org>
Authored: Sun May 27 12:10:59 2018 -0700
Committer: John Wagenleitner <jw...@apache.org>
Committed: Sun May 27 13:09:46 2018 -0700

----------------------------------------------------------------------
 .../org/codehaus/groovy/runtime/DefaultGroovyMethods.java     | 2 +-
 .../transform/stc/ClosureParamTypeInferenceSTCTest.groovy     | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/72e530db/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
index 1429102..659a397 100644
--- a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
@@ -3499,7 +3499,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
      * @return a List of the transformed values
      * @since 2.5.0
      */
-    public static <S,T> List<T> collect(Iterator<S> self, @ClosureParams(FirstParam.Component.class) Closure<T> transform) {
+    public static <S,T> List<T> collect(Iterator<S> self, @ClosureParams(FirstParam.FirstGenericType.class) Closure<T> transform) {
         return (List<T>) collect(self, new ArrayList<T>(), transform);
     }
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/72e530db/src/test/groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy b/src/test/groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy
index 493802e..0e7f296 100644
--- a/src/test/groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy
+++ b/src/test/groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy
@@ -231,6 +231,13 @@ def items = []
         '''
     }
 
+    void testDGM_collectOnIterator() {
+        assertScript '''
+            Iterator<String> itr = ['foo', 'bar', 'baz'].iterator()
+            assert itr.collect { it.startsWith('ba') } == [false, true, true]
+        '''
+    }
+
     void testInferenceOnNonExtensionMethod() {
         assertScript '''import groovy.transform.stc.ClosureParams
             import groovy.transform.stc.FirstParam