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 2023/06/10 17:56:57 UTC

[groovy] branch master updated: GROOVY-11090: add test cases

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

emilles 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 0581a79f3b GROOVY-11090: add test cases
0581a79f3b is described below

commit 0581a79f3b18a25aa36a0d70428c0fe4c52b1dd4
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sat Jun 10 12:53:22 2023 -0500

    GROOVY-11090: add test cases
---
 .../stc/ClosureParamTypeInferenceSTCTest.groovy    | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/src/test/groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy b/src/test/groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy
index c929b3df8d..3e2cbeb105 100644
--- a/src/test/groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy
+++ b/src/test/groovy/transform/stc/ClosureParamTypeInferenceSTCTest.groovy
@@ -167,6 +167,34 @@ class ClosureParamTypeInferenceSTCTest extends StaticTypeCheckingTestCase {
         'Incorrect number of parameters. Expected 1 or 2 but found 3'
     }
 
+    // GROOVY-11090
+    void testFromStringWithGenericType4() {
+        assertScript '''
+            void foo(@ClosureParams(value=FromString, options="List<Tuple2<String,Number>>") Closure c) {
+                c.call(Collections.singletonList(Tuple.tuple("",(Number)42)))
+            }
+            foo {
+                it.each { string, number ->
+                    number.doubleValue()
+                    string.toUpperCase()
+                }
+            }
+        '''
+    }
+
+    void testFromStringWithGenericType5() {
+        assertScript '''
+            void foo(@ClosureParams(value=FromString, options="Optional<Tuple2<String,? extends Number>>") Closure c) {
+                c(Optional.of(Tuple.tuple("",42)))
+            }
+            foo { opt ->
+                opt.ifPresent {
+                    it.v2.doubleValue()
+                }
+            }
+        '''
+    }
+
     void testFromStringWithTypeParameter1() {
         assertScript '''
             def <T> void foo(T t, @ClosureParams(value=FromString, options="T") Closure c) { c.call(t) }