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

paulk-asert 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 523fd1ed16 GROOVY-12117: Add a test to lock-in required trait ordering
523fd1ed16 is described below

commit 523fd1ed16602900dfbcf6c72591227bf1207133
Author: Paul King <[email protected]>
AuthorDate: Thu Jul 9 11:38:11 2026 +1000

    GROOVY-12117: Add a test to lock-in required trait ordering
---
 .../codehaus/groovy/transform/traitx/Groovy11985.groovy | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git 
a/src/test/groovy/org/codehaus/groovy/transform/traitx/Groovy11985.groovy 
b/src/test/groovy/org/codehaus/groovy/transform/traitx/Groovy11985.groovy
index 5a4628f07c..29c62221ce 100644
--- a/src/test/groovy/org/codehaus/groovy/transform/traitx/Groovy11985.groovy
+++ b/src/test/groovy/org/codehaus/groovy/transform/traitx/Groovy11985.groovy
@@ -131,6 +131,23 @@ final class Groovy11985 {
         '''
     }
 
+    @Test
+    void testSuperTraitPublicStaticIsPolymorphicSubTraitFirst() {
+        // As above, but the sub-trait is declared FIRST so it is lowered while
+        // the super-trait's helper is still a stub (GROOVY-12117). The stub 
must
+        // carry @Virtual, else dispatch silently falls back to declarer-bound 
and
+        // D.greet() returns 'base' instead of the implementer's 'override'.
+        GroovyAssert.assertScript '''
+            import groovy.transform.Virtual
+            trait Mid extends Base { static String greet() { hello() } }
+            trait Base { @Virtual static String hello() { 'base' } }
+            class C implements Mid {}
+            class D implements Mid { static String hello() { 'override' } }
+            assert C.greet() == 'base'
+            assert D.greet() == 'override'
+        '''
+    }
+
     @Test
     void testPrivateStaticStillRoutesToHelper() {
         // Private statics are not composed onto the implementer, so they must

Reply via email to