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 2022/03/30 17:44:15 UTC

[groovy] 02/02: GROOVY-10557: add test case

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

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

commit 09b1226739a88347ac453488d939084d6fd4e58f
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Wed Mar 30 10:06:00 2022 -0500

    GROOVY-10557: add test case
---
 src/test/groovy/transform/stc/GenericsSTCTest.groovy | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/test/groovy/transform/stc/GenericsSTCTest.groovy b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
index c1a74d6..c7bfe1b 100644
--- a/src/test/groovy/transform/stc/GenericsSTCTest.groovy
+++ b/src/test/groovy/transform/stc/GenericsSTCTest.groovy
@@ -3395,6 +3395,23 @@ class GenericsSTCTest extends StaticTypeCheckingTestCase {
         '''
     }
 
+    // GROOVY-10557
+    void testReturnTypeInferenceWithClosure2() {
+        assertScript '''
+            import java.util.function.Function
+            class C {
+                final <T> T m(Function<Reader,T> function)  {
+                    new StringReader("").withCloseable { reader ->
+                        function.apply(reader)
+                    }
+                }
+            }
+            Object result = new C().m { it.text.empty }
+            //                          ^^ StringReader
+            assert result == Boolean.TRUE
+        '''
+    }
+
     // GROOVY-6129
     void testShouldNotThrowNPE() {
         assertScript '''