[ 
https://issues.apache.org/jira/browse/GROOVY-12608?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18137372#comment-18137372
 ] 

ASF GitHub Bot commented on GROOVY-12608:
-----------------------------------------

testlens-app[bot] commented on PR #3135:
URL: https://github.com/apache/groovy/pull/3135#issuecomment-6609667374

   ## ✅ All tests passed ✅
   
   🏷️ Commit: 59121fd7933cf86d284f6c138d0dc5658204285b
   ▶️ Tests:  116199 executed
   ⚪️ Checks: 26/26 completed
   
   ---
   _Learn more about TestLens at 
[testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
   




> SC calls a super trait's static accessor, read as a property in a closure or 
> lambda, with the trait instead of the implementing class
> -------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12608
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12608
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> {code:groovy}
> @groovy.transform.CompileStatic
> trait T { private static int count = 1; static int getCnt() { count } }
> @groovy.transform.CompileStatic
> trait U extends T { String m() { def c = { -> cnt }; c() } }
> class C implements U {}
> assert new C().m() == '1'
> {code}
> Actual: MissingMethodException: No signature of static method: T__count$get 
> for class: T is applicable for argument types: () values: []
> The same happens in a lambda, in a static trait method, and for a super 
> trait's static property such as static int shared = 3. Writing such a 
> property in a closure (cnt = n, cnt++, s = 'y') fails to compile under 
> @TypeChecked and @CompileStatic: "Cannot set read-only property: cnt".
> Expected: the assertion passes, as it does in dynamic Groovy and with 
> getCnt(). A delegate that has the property still comes first (p.with ... cnt).
> The static compiler calls the static method on the super trait interface, 
> which passes the trait itself to the trait helper as the receiver class. The 
> type checker looks for setters only on the receiver type, where a static 
> interface method is not inherited.
> Seen on master with PR #3115 (GROOVY-12590) applied, which fixes the same 
> call outside closures. 6.0.0 fails the same way.
> PR: https://github.com/apache/groovy/pull/3135



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to