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

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

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

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




> STC accepts access to a private superclass field through a nested subclass 
> under @TypeChecked, which fails at run time
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12610
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12610
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 4.0.33, 5.0.8, 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> {code:groovy}
> class Base {
>     private String z = 'x'
>     @groovy.transform.TypeChecked
>     static class Sub extends Base {
>         def m() { this.z }   // also: z, super.z, closures, lambdas, writes, 
> that.z
>     }
> }
> new Base.Sub().m()
> {code}
> Actual: the code compiles, then fails with MissingPropertyException: No such 
> property: z for class: Base$Sub. Dynamic Groovy fails the same way.
> Expected: under @TypeChecked, a compile error "No such property: z for class: 
> Base$Sub", as already reported when Base and Sub are both nested in another 
> class. @CompileStatic keeps accepting the code, because it accesses the field 
> directly from a nest-mate.
> Cause: the type checker uses the nest-mate accessibility rule of static 
> compilation for @TypeChecked code too. Type-checked code is dispatched 
> dynamically, and the metaclass of a subclass does not list a private field of 
> its superclass.
> Seen in 4.0.33, 5.0.8 and 6.0.0.
> PR: https://github.com/apache/groovy/pull/3137



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

Reply via email to