[
https://issues.apache.org/jira/browse/GROOVY-12597?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18137360#comment-18137360
]
ASF GitHub Bot commented on GROOVY-12597:
-----------------------------------------
testlens-app[bot] commented on PR #3124:
URL: https://github.com/apache/groovy/pull/3124#issuecomment-6609518105
## ✅ All tests passed ✅
🏷️ Commit: e099995bd30501bc66636743b77372b2e96766ce
▶️ Tests: 117041 executed
⚪️ Checks: 26/26 completed
---
_Learn more about TestLens at
[testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
> Calling a stateful trait static method through the trait fails with
> MissingMethodException for the internal field accessor
> --------------------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12597
> URL: https://issues.apache.org/jira/browse/GROOVY-12597
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 6.0.0
> Reporter: Scott Murphy Heiberg
> Priority: Major
>
> {code:groovy}
> trait T {
> private static boolean flag = true
> static boolean isReady() { flag }
> }
> class C implements T {}
> assert C.isReady()
> assert T.isReady()
> {code}
> Actual: {{T.isReady()}} (and {{T.ready}}) throws
> {{groovy.lang.MissingMethodException: No signature of static method:
> T__flag$get for class: T is applicable for argument types: () values: []}}.
> The same happens in dynamic Groovy, with @TypeChecked and with
> @CompileStatic, and for static properties, setters, closures and private
> static helpers.
> Expected: trait static state belongs to each implementing class, so the trait
> itself has none. The call should fail with an error that says so, not with a
> missing internal accessor. Stateless static methods called through the trait
> keep working.
> Cause: the promoted interface static forwarder passes the trait class as the
> static self of the helper method. A static field access in the helper becomes
> a call to the generated accessor (here T__flag$get) on that class, and only
> implementing classes declare one.
> Seen in 6.0.0. 5.x does not promote trait statics onto the interface.
> PR: https://github.com/apache/groovy/pull/3124
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)