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

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

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

   ## 🚨 All tests passed but jobs failed 🚨
   
   ### Failed Jobs without Test Failures
   
   ❌ [Generate SNAPSHOT distributions / 
dist](https://github.com/apache/groovy/actions/runs/44132490553/job/134213039901?pr=3153)
   
   🏷️ Commit: 330cf2a219a6d3037a5f4df9c0e8cc91635456f2
   ▶️ Tests:  8917 executed
   🟡 Checks: 5/25 completed
   
   ### Rerun Controls
   
   Click the checkbox to trigger a rerun:
   
   🔲 **Rerun jobs**
   
   ---
   _Learn more about TestLens at 
[testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
   




> Writing a property of the enclosing instance from a closure in an inner class 
> throws MissingPropertyException unless the receiver is a plain this
> -------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12627
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12627
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> {code:groovy}
> class Base {
>     private String z = 'outer'
>     class Sub extends Base {
>         def m() { { -> Sub.this.z = 'w' }(); Base.this.z }
>     }
>     def t() { new Sub().m() }
> }
> assert new Base().t() == 'w'
> {code}
> Actual: groovy.lang.MissingPropertyException: No such property: z for class: 
> Base$Sub
> Expected: 'w'. The write goes to the enclosing instance, as this.z = 'w' in 
> the closure does, as Sub.this.z = 'w' outside the closure does, and as 
> reading Sub.this.z in the closure does. Groovy 4.0.33, 5.0.8 and 5.1.3 return 
> 'w'.
> The same happens for s.z = 'w' with def s = this (also under @TypeChecked), 
> for compound assignment and ++, for nested closures and lambdas, for a 
> non-subclass inner class (Inner.this.z = 'w'), and for a spread-dot read or 
> write in a closure.
> A call site in a closure passes the closure class as the sender. The 
> enclosing-instance fallback that GROOVY-11823 added to MetaClassImpl checks 
> the nesting of that closure class rather than of the class that declares the 
> closure, so it never applies there.
> Seen in 6.0.0 (regression); 4.0.33, 5.0.8 and 5.1.3 work.
> PR: https://github.com/apache/groovy/pull/3153



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

Reply via email to