You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2019/11/02 14:39:58 UTC

[groovy] branch GROOVY_3_0_X updated: Add a test for `with` under STC mode

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

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


The following commit(s) were added to refs/heads/GROOVY_3_0_X by this push:
     new 78eb68e  Add a test for `with` under STC mode
78eb68e is described below

commit 78eb68e62158aa7319bc51c2e761c3fa22e6c406
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Nov 2 22:38:29 2019 +0800

    Add a test for `with` under STC mode
    
    (cherry picked from commit 6a38f524ecbba56673521613557da2e647a6c9c3)
---
 src/test/groovy/transform/stc/WithSTCTest.groovy | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/test/groovy/transform/stc/WithSTCTest.groovy b/src/test/groovy/transform/stc/WithSTCTest.groovy
index afae05c..083346a 100644
--- a/src/test/groovy/transform/stc/WithSTCTest.groovy
+++ b/src/test/groovy/transform/stc/WithSTCTest.groovy
@@ -48,5 +48,18 @@ class WithSTCTest extends StaticTypeCheckingTestCase {
             assert Test.a( 'TIM' ) == 'tim'
         '''
     }
-}
 
+    void testIntReturnType() {
+        assertScript '''
+            class Test {
+               static int a(String s) {
+                    s.toCharArray().with {
+                        length
+                    }
+                }
+            }
+
+            assert Test.a( 'Daniel' ) == 6 
+        '''
+    }
+}