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

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

codeconsole commented on PR #3150:
URL: https://github.com/apache/groovy/pull/3150#issuecomment-6717052055

   @daniellansun I can't re-run jobs on apache/groovy, so I merged current 
master (492ae79db4) to get a fresh run, which also brings in the Windows Gradle 
cache fix (#3110). The failed cell was `lts (17, windows-latest, 1)`. No code 
changes; the core test suite (19,690 tests) passes locally on the merge.
   




> 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