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:38:41 UTC

[groovy] branch master 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 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 6a38f52  Add a test for `with` under STC mode
6a38f52 is described below

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

    Add a test for `with` under STC mode
---
 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 
+        '''
+    }
+}