[
https://issues.apache.org/jira/browse/GROOVY-12614?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18144450#comment-18144450
]
ASF GitHub Bot commented on GROOVY-12614:
-----------------------------------------
testlens-app[bot] commented on PR #3297:
URL: https://github.com/apache/groovy/pull/3297#issuecomment-6855647813
## ✅ All tests passed ✅
🏷️ Commit: 8c291d45f0522cd82f49aca81b3574c1a7885357
▶️ Tests: 132448 executed
⚪️ Checks: 26/26 completed
---
_Learn more about TestLens at
[testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
> Trait code reads a plain static accessor as a property through the
> implementing class in dynamic and @TypeChecked code, but declarer-bound under
> @CompileStatic and in the method form
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12614
> URL: https://issues.apache.org/jira/browse/GROOVY-12614
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 6.0.0
> Reporter: Scott Murphy Heiberg
> Priority: Major
>
> {code:groovy}
> trait T {
> static String getLabel() { 'trait' }
> static String sm() { label } // property form
> static String sm2() { getLabel() } // method form
> }
> class C implements T { static String getLabel() { 'impl' } }
> class D implements T {}
> println([C.sm(), D.sm(), C.sm2(), D.sm2()])
> {code}
> Dynamic and @TypeChecked: [impl, trait, trait, trait]
> @CompileStatic: [trait, trait, trait, trait]
> The property form of a plain (non-@Virtual) static accessor, read from trait
> code, dispatches through the implementing class in dynamic and type-checked
> code, but is declarer-bound under static compilation, and the method form is
> declarer-bound in every mode. The same holds for this.label, for an instance
> trait method, inside closures, and for an accessor of a super trait. A
> field-backed static property is declarer-bound in all modes.
> The traits guide says public statics are declarer-bound by default for calls
> from other trait code and that @Virtual opts into implementing-class dispatch
> ("For overridable static data rather than behaviour, use a @Virtual
> accessor"). VirtualAnnotationTest/TraitStaticDispatchMatrix row09vget adds
> @Virtual to get exactly the override-visible property read. But
> TraitStaticDispatchMatrix.row09acc_accessorPattern_overrideVisibleToTraitBody
> asserts the dynamic behaviour ("origin is class" for a plain accessor), with
> a comment pointing at row 1's dispatch path, which since "GROOVY-12093
> adjusted: out with @Anchored in with @Virtual" requires @Virtual. row09acc
> looks like it predates that change.
> Question: which is intended? If declarer-bound is the rule,
> TraitReceiverTransformer should call the helper for a property read or write
> of a plain static accessor, as it does for the method form, and row09acc
> should expect "origin is trait" (or move to @Virtual). If row09acc is the
> rule, static compilation and the method form disagree with it. I can provide
> the PR either way.
> Seen in 6.0.0 and on master.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)