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

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

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

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




> SC resolves calls that the trait transformation adds in a closure against the 
> closure's delegate
> ------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12624
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12624
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> {code:groovy}
> @groovy.transform.CompileStatic
> trait V {
>     static String who() { this.simpleName }
>     def m() { new Object().with { who() } }
> }
> class E implements V {}
> assert new E().m() == 'E'
> class Dg {
>     String who(Class c) { 'delegate' }
> }
> @groovy.transform.CompileStatic
> trait T {
>     static String who() { this.simpleName }
>     def m() { new Dg().with { who() } }
> }
> class C implements T {}
> assert new C().m() == 'C'
> {code}
> Actual: under static compilation the first m() returns 'Object' (the 
> delegate's class), also when who is declared in a super trait or called as 
> this.who(). The second m() returns 'delegate': it calls Dg.who(Class) with 
> the self argument that the trait transformation added.
> Expected: 'E' and 'C', as dynamic Groovy and @TypeChecked return.
> Cause: TraitReceiverTransformer rewrites the call to a trait helper call with 
> the receiver class as first argument. Both the outer helper call and the 
> inner getClass() call keep the default implicit-this flag, so the static 
> compiler resolves them against the closure's delegate.
> Seen on master; 5.0.8 and 6.0.0 reported the same.
> PR: https://github.com/apache/groovy/pull/3150



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

Reply via email to