groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From emil...@apache.org
Subject [groovy] branch master updated: GROOVY-9973: add test case
Date Tue, 09 Mar 2021 15:31:25 GMT
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 4eede99  GROOVY-9973: add test case
4eede99 is described below

commit 4eede99c271fed83f35a7e5ad06677d4002c7dc7
Author: Eric Milles <eric.milles@thomsonreuters.com>
AuthorDate: Tue Mar 9 09:31:14 2021 -0600

    GROOVY-9973: add test case
---
 .../stc/FieldsAndPropertiesSTCTest.groovy          | 34 ++++++++++++++++------
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/src/test/groovy/transform/stc/FieldsAndPropertiesSTCTest.groovy b/src/test/groovy/transform/stc/FieldsAndPropertiesSTCTest.groovy
index 5fca628..ac885b7 100644
--- a/src/test/groovy/transform/stc/FieldsAndPropertiesSTCTest.groovy
+++ b/src/test/groovy/transform/stc/FieldsAndPropertiesSTCTest.groovy
@@ -250,21 +250,37 @@ class FieldsAndPropertiesSTCTest extends StaticTypeCheckingTestCase
{
         '''
     }
 
-    void testMethodUsageForProperty() {
+    void testDateProperties() {
         assertScript '''
-            class Foo {
-                String name
+            Date d = new Date()
+            def time = d.time
+            d.time = 0
+        '''
+    }
+
+    void testGetterForProperty1() {
+        assertScript '''
+            class C {
+                String p
             }
-            def name = new Foo().getName()
-            name?.toUpperCase()
+            def x = new C().getP()
+            x = x?.toUpperCase()
         '''
     }
 
-    void testDateProperties() {
+    // GROOVY-9973
+    void testGetterForProperty2() {
         assertScript '''
-            Date d = new Date()
-            def time = d.time
-            d.time = 0
+            class C {
+                private int f
+                int getP() { f }
+                Integer m() { 123456 - p }
+                Integer m(int i) { i - p }
+            }
+
+            def c = new C()
+            assert c.m() == 123456 // BUG! exception in phase 'class generation' ...
+            assert c.m(123) == 123 // ClassCastException: class org.codehaus.groovy.ast.Parameter
cannot be cast to ...
         '''
     }
 


Mime
View raw message