You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2026/06/28 01:05:38 UTC
(groovy) 02/02: GROOVY-12106: STC cannot resolve inherited static trait method from sub-trait body (port for GROOVY_5_0_X)
This is an automated email from the ASF dual-hosted git repository.
paulk-asert pushed a commit to branch GROOVY_5_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit b46ebb25e7bcba7269c9185aa0e965e02c50db06
Author: Paul King <pa...@asert.com.au>
AuthorDate: Sun Jun 28 11:05:27 2026 +1000
GROOVY-12106: STC cannot resolve inherited static trait method from sub-trait body (port for GROOVY_5_0_X)
---
.../groovy/transform/traitx/Groovy12106.groovy | 5 +++++
.../transform/traitx/TraitStaticDispatchMatrix.groovy | 19 +++++++++++++++++--
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/src/test/groovy/org/codehaus/groovy/transform/traitx/Groovy12106.groovy b/src/test/groovy/org/codehaus/groovy/transform/traitx/Groovy12106.groovy
index fd18ea3954..e8f87d7198 100644
--- a/src/test/groovy/org/codehaus/groovy/transform/traitx/Groovy12106.groovy
+++ b/src/test/groovy/org/codehaus/groovy/transform/traitx/Groovy12106.groovy
@@ -18,6 +18,7 @@
*/
package org.codehaus.groovy.transform.traitx
+import groovy.test.NotYetImplemented
import org.junit.Test
import static groovy.test.GroovyAssert.assertScript
@@ -74,6 +75,10 @@ final class Groovy12106 {
'''
}
+ // On GROOVY_5_0_X: @NotYetImplemented — the qualified form resolves via the trait's
+ // promoted interface static (GROOVY-12111), which is master-only; the unqualified and
+ // this.-qualified forms above (the GROOVY-12106 fix) work here, but Parent.m(...) does not.
+ @NotYetImplemented
@Test
void testQualifiedInheritedStaticWithSubtypeArg() {
assertScript '''
diff --git a/src/test/groovy/org/codehaus/groovy/transform/traitx/TraitStaticDispatchMatrix.groovy b/src/test/groovy/org/codehaus/groovy/transform/traitx/TraitStaticDispatchMatrix.groovy
index 3cbb82f6f6..ad2fd63742 100644
--- a/src/test/groovy/org/codehaus/groovy/transform/traitx/TraitStaticDispatchMatrix.groovy
+++ b/src/test/groovy/org/codehaus/groovy/transform/traitx/TraitStaticDispatchMatrix.groovy
@@ -36,6 +36,7 @@
package org.codehaus.groovy.transform.traitx
import groovy.test.GroovyAssert
+import groovy.test.NotYetImplemented
import org.codehaus.groovy.control.MultipleCompilationErrorsException
import org.junit.Test
@@ -268,6 +269,9 @@ class TraitStaticDispatchMatrix {
// (public trait statics are promoted onto the trait interface). The
// trait's own copy wins; any same-named static on the implementer is
// an independent method, not an override (declarer-bound dispatch).
+ // On GROOVY_5_0_X: @NotYetImplemented — interface promotion of trait statics
+ // (GROOVY-12111) is master-only, so T.m() from trait code does not resolve here yet.
+ @NotYetImplemented
@Test
void row07_traitQualified_resolvesViaInterfaceStatic() {
def r = ev '''
@@ -284,6 +288,9 @@ class TraitStaticDispatchMatrix {
// ---- Row 8 — external Impl.m() works AND external Trait.m() works ----
// Public trait statics are JVM-native interface statics, so both
// forms of external access resolve cleanly.
+ // On GROOVY_5_0_X: @NotYetImplemented — external Trait.m() needs interface promotion
+ // (GROOVY-12111, master-only); Impl.m() works but the Trait.m() assertion fails here.
+ @NotYetImplemented
@Test
void row08_externalAccess() {
assert ev('trait T { static String foo() { "ok" } }\nclass C implements T {}\nC.foo()') == 'ok'
@@ -453,8 +460,11 @@ class TraitStaticDispatchMatrix {
// `T.this.m()` inside trait code currently produces invalid bytecode
// (VerifyError on 4.x: "Class not assignable to Closure"; ClassCastException
// at runtime on 5.x/6.x). GEP-22 § "this, super, and stackable traits"
- // item 4 proposes rejecting the syntax at compile time. NYI until the
- // fix lands; flips red on a build that implements the rejection.
+ // item 4 proposes rejecting the syntax at compile time.
+ // On GROOVY_5_0_X: @NotYetImplemented — the compile-time rejection (GROOVY-12104) is
+ // master-only; here T.this.* still produces the runtime ClassCastException, so the
+ // expected compile error does not occur yet.
+ @NotYetImplemented
@Test
void row14_T_this_qualifier_inTrait_isCompileError() {
GroovyAssert.shouldFail(MultipleCompilationErrorsException) {
@@ -476,6 +486,10 @@ class TraitStaticDispatchMatrix {
// pointing at `T.super.m()` as the explicit form. See Groovy12105.groovy
// for focused coverage (regression-guards for the instance-method and
// plain-class super-call cases). This row is the matrix-level anchor.
+ // On GROOVY_5_0_X: @NotYetImplemented — the compile-time rejection (GROOVY-12105) is
+ // master-only; here unqualified static super still throws MissingMethodException at
+ // runtime, so the expected compile error does not occur yet.
+ @NotYetImplemented
@Test
void row15_unqualified_static_super_inTrait_isCompileError() {
GroovyAssert.shouldFail(MultipleCompilationErrorsException) {
@@ -574,6 +588,7 @@ class TraitStaticDispatchMatrix {
// success state, so it tracks the genuinely-correct end-state rather than any prior
// partial behaviour.
@Test
+ @NotYetImplemented
void row16q_childTrait_inheritedParentStatic_subtypeArg_qualified() {
def r = ev '''
import groovy.transform.CompileStatic