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

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

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

   ## 🚨 All tests passed but jobs failed 🚨
   
   ### Failed Jobs without Test Failures
   
   ❌ [Build and test / lts \(25, 
ubuntu-latest\)](https://github.com/apache/groovy/actions/runs/41153849315/job/124396193613?pr=3050)
   
   🏷️ Commit: 5f9cbd033edf9f89a4859150a81e28e9de341918
   ▶️ Tests:  2055 executed
   🟡 Checks: 5/24 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/)._
   




> STC: x.@name is accepted for a private field of a superclass when the type of 
> x is a subclass
> ---------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12523
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12523
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> In a class nested in {{Outer}}, the type checker accepts {{sub.@f}}, where 
> {{f}} is a private field of {{Outer}} and {{sub}} is typed as a subclass of 
> {{Outer}}:
> {code:groovy}
> @groovy.transform.TypeChecked
> class Outer {
>     private String f = 'outer'
>     static class Sub extends Outer {
>         String read(Sub sub) { sub.@f }
>     }
> }
> new Outer.Sub().read(new Outer.Sub()) // MissingFieldException: No such 
> field: f for class: Outer$Sub
> {code}
> Dynamic Groovy and {{@TypeChecked}} throw {{MissingFieldException}}, because 
> the meta-class of a subclass offers no private field of its superclass. 
> {{@CompileStatic}} reads the field. javac rejects {{sub.f}} ("f has private 
> access in Outer"), since a private field is not a member of a subclass (JLS 
> 8.2). With {{f}} declared in a nested class {{Box}} and {{Sub extends Box}}, 
> or with a top-level subclass, the type checker already rejects {{sub.@f}} 
> with "Cannot access field". Seen in 5.0.8, 6.0.0 and master; 4.0.33 failed at 
> run time in every mode.
> Expected: "Cannot access field: f of class: Outer", also for writes, 
> closures, lambdas and {{new Sub().@f}}. {{this.@f}}, {{super.@f}}, {{((Outer) 
> sub).@f}} and {{sub.@f}} inside {{Outer}} keep compiling.
> PR: https://github.com/apache/groovy/pull/3050



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

Reply via email to