groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwagenleit...@apache.org
Subject groovy git commit: GROOVY-8610: STC NPE using DGM collect on Iterator (closes #729)
Date Sun, 27 May 2018 20:41:51 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_6_X fcdc0e9e8 -> 4a327f2b1


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

(cherry picked from commit 72e530db3bb87644cc989039c31381e7f6ab68dc)


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

Branch: refs/heads/GROOVY_2_6_X
Commit: 4a327f2b18ddd89b41ebd86583b46cec0be8750a
Parents: fcdc0e9
Author: John Wagenleitner <jwagenleitner@apache.org>
Authored: Sun May 27 12:10:59 2018 -0700
Committer: John Wagenleitner <jwagenleitner@apache.org>
Committed: Sun May 27 13:40:44 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/4a327f2b/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 0e4150f..51062b5 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/4a327f2b/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 ab818af..53f614b 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


Mime
View raw message