jamesfredley commented on PR #15557:
URL: https://github.com/apache/grails-core/pull/15557#issuecomment-4819057560

   ### Update: tracking `5.0.7-SNAPSHOT` again + new GraphQL trait-static 
workaround
   
   Pushed `0035ca1b58`.
   
   **Why the version moved back to a snapshot.** This PR had pinned the 
released Groovy `5.0.7` coordinate. Two problems:
   
   1. Groovy `5.0.7` has not actually shipped - the `GROOVY_5_0_X` branch is 
still `5.0.7-SNAPSHOT`.
   2. The experimental `@Anchored` trait-static annotation this PR briefly 
relied on was **voted down by the Groovy PMC and removed upstream** in 
[GROOVY-12093](https://issues.apache.org/jira/browse/GROOVY-12093) (commit 
[`e83dd19b`](https://github.com/apache/groovy/commit/e83dd19b6181c23f3d47241b25edb33642c0a92c),
 *"out with `@Anchored` in with `@Virtual`"*). `groovy.transform.Anchored` no 
longer exists; it is replaced by `groovy.transform.Virtual`.
   
   So `dependencies.gradle` now tracks `5.0.7-SNAPSHOT` (the build that 
contains the replacement model), and the affected Grails-side workaround is 
adapted to it.
   
   **Why `@Virtual` is not a drop-in replacement here.** `@Anchored` let a 
child trait call a parent trait's `static` helper 
(`ExecutesClosures.withDelegate(...)`) under `@CompileStatic`. The replacement 
`@Virtual` does something different: it only restores *per-implementer 
override* dispatch for calls made from the **same trait** or an **implementing 
class** (the `Validateable.defaultNullable()`-style hook). It does **not** make 
a *child* `@CompileStatic` trait resolve an **inherited parent-trait static**. 
I verified this empirically with full Gradle compiles against a freshly 
re-downloaded `5.0.7-SNAPSHOT`:
   
   | Attempt | Result |
   |---|---|
   | plain `static` + `ExecutesClosures.withDelegate(...)` (qualified) | STC 
error: `Cannot find matching method java.lang.Class#withDelegate(...)` |
   | `@Virtual` + `ExecutesClosures.withDelegate(...)` (qualified) | same 
`java.lang.Class#withDelegate` error |
   | `@Virtual` + `withDelegate(...)` (unqualified, inherited) | STC error: 
`Cannot find matching method ...Arguable#withDelegate(...)` |
   
   This matches Groovy's own `TraitStaticDispatchMatrix` (rows 7/8: 
trait-qualified static access throws / is unsupported) and 
`VirtualAnnotationTest` (every `@Virtual` case is a same-trait or 
implementing-class call, never a child-trait→parent-trait inherited static).
   
   **The workaround.** Since no `@Virtual` call form compiles for the 
cross-trait case, the GraphQL helper goes back to the approach that predated 
`@Anchored`:
   
   - `ExecutesClosures.withDelegate` stays a plain `static` method (still the 
trait's public contract for implementing classes - just without 
`@Anchored`/`@Virtual`).
   - `Arguable` and `ComplexTyped` re-inline the null-safe `DELEGATE_ONLY` 
closure logic instead of calling the parent-trait static.
   
   **Verification** (against fresh `5.0.7-SNAPSHOT`, Groovy snapshot caches 
flushed before re-resolve):
   
   - `./gradlew :grails-data-graphql-core:compileGroovy 
:grails-data-graphql-core:compileTestGroovy --rerun-tasks 
--refresh-dependencies` - BUILD SUCCESSFUL
   - `./gradlew :grails-data-graphql-core:test` - all specs PASSED
   - `./gradlew :grails-data-graphql-core:codeStyle` - PASSED (Checkstyle + 
CodeNarc)
   - `git diff --check` - clean
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to