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 5949c28866 GROOVY-8029: add test case
5949c28866 is described below

commit 5949c2886689696bdb8fd98b16f23aaa23072885
Author: Eric Milles <[email protected]>
AuthorDate: Fri Nov 3 13:15:24 2023 -0500

    GROOVY-8029: add test case
---
 src/test/groovy/transform/stc/TernaryOperatorSTCTest.groovy | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/test/groovy/transform/stc/TernaryOperatorSTCTest.groovy 
b/src/test/groovy/transform/stc/TernaryOperatorSTCTest.groovy
index 5da7589b2a..61fbc15e00 100644
--- a/src/test/groovy/transform/stc/TernaryOperatorSTCTest.groovy
+++ b/src/test/groovy/transform/stc/TernaryOperatorSTCTest.groovy
@@ -147,6 +147,17 @@ class TernaryOperatorSTCTest extends 
StaticTypeCheckingTestCase {
         '''
     }
 
+    // GROOVY-8029
+    void testListLiteralAndListCoerce() {
+        assertScript '''
+            List<String> getStrings(List<Object> list) {
+                list.collectMany{ [it.toString()] } ?: ([] as List<String>)
+            }
+            assert getStrings([]).isEmpty()
+            assert getStrings([new Object(), new String()]).size() == 2
+        '''
+    }
+
     // GROOVY-10330
     void testTypeParameterTypeParameter1() {
         assertScript '''

Reply via email to