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 750172d  GROOVY-10521: add test case
750172d is described below

commit 750172d5728b313affebc3858a41618623b8168f
Author: Eric Milles <[email protected]>
AuthorDate: Sat Mar 5 13:22:03 2022 -0600

    GROOVY-10521: add test case
---
 .../traitx/TraitASTTransformationTest.groovy       | 50 +++++++++++++++++-----
 1 file changed, 39 insertions(+), 11 deletions(-)

diff --git 
a/src/test/org/codehaus/groovy/transform/traitx/TraitASTTransformationTest.groovy
 
b/src/test/org/codehaus/groovy/transform/traitx/TraitASTTransformationTest.groovy
index b49bb91..ca9289e 100644
--- 
a/src/test/org/codehaus/groovy/transform/traitx/TraitASTTransformationTest.groovy
+++ 
b/src/test/org/codehaus/groovy/transform/traitx/TraitASTTransformationTest.groovy
@@ -2954,6 +2954,33 @@ final class TraitASTTransformationTest {
         }
     }
 
+    trait T10521 {
+        def m(Class<?> clazz, Object... array) {
+            clazz.name + array
+        }
+    }
+
+    @Test // GROOVY-10521
+    void testVariadicMethodOfPrecompiledTrait() {
+        
System.setProperty('spock.iKnowWhatImDoing.disableGroovyVersionCheck','true')
+        assertScript """
+            @Grab('org.spockframework:spock-core:2.2-M1-groovy-4.0')
+            @GrabExclude('org.apache.groovy:*')
+            import spock.lang.Specification
+
+            class C extends Specification implements ${T10521.name} {
+                void test() {
+                  when:
+                    String result = m(Object,'x')
+                  then:
+                    result == 'java.lang.Object[x]'
+                }
+            }
+
+            org.junit.runner.JUnitCore.runClasses(C)
+        """
+    }
+
     @Test // GROOVY-7287
     void testTraitWithMethodLevelGenericsShadowing1() {
         assertScript '''
@@ -3018,21 +3045,22 @@ final class TraitASTTransformationTest {
         '''
     }
 
+    trait T7297 {
+        String title
+        def <U> List<U> m(U data) {
+            [data]
+        }
+    }
+
     @Test // GROOVY-7297
-    void testMethodlevelGenericsFromPrecompiledClass() {
-        // TODO: T needs to be outside the script
-        assertScript '''
-            trait T {
-                String title
-                public <U> List<U> m(U data) {
-                }
-            }
-            class C implements T {
+    void testMethodLevelGenericsFromPrecompiledClass() {
+        assertScript """
+            class C implements ${T7297.name} {
             }
             def c = new C(title: 'some title')
             assert c.title == 'some title'
-            // TODO: assert c.m(...) == ?
-        '''
+            assert c.m('x') == ['x']
+        """
     }
 
     @Test // GROOVY-9763

Reply via email to