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

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

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

   ## 🚨 All tests passed but jobs failed 🚨
   
   ### Failed Jobs without Test Failures
   
   ❌ [Build and test for coverage / 
test](https://github.com/apache/groovy/actions/runs/41177667983/job/124468476047?pr=3147)
   
   🏷️ Commit: 8ac5cd2c1981d938562be12f71374404cc5e11be
   ▶️ Tests:  71762 executed
   🟡 Checks: 9/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 still accepts some private superclass field accesses under @TypeChecked 
> that fail at run time
> -------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12621
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12621
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 4.0.33, 5.0.8, 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> GROOVY-12610 makes the type checker reject property access to a private 
> instance field of a superclass when dynamic dispatch can never find it. Three 
> shapes are still accepted and fail with a MissingPropertyException.
> Enum constant body (z, this.z and super.z all fail):
> {code:groovy}
> @groovy.transform.TypeChecked
> enum E {
>     A { def n() { z } }
>     private String z = 'x'
> }
> E.A.n()
> {code}
> Write through super in a non-static inner subclass (compound assignment and 
> increment also fail):
> {code:groovy}
> @groovy.transform.TypeChecked
> class Base {
>     private String z = 'x'
>     class Sub extends Base {
>         def m() { super.z = 'y' }
>     }
>     def t() { new Sub().m() }
> }
> new Base().t()
> {code}
> Receiver that is not an instance of the calling inner class:
> {code:groovy}
> @groovy.transform.TypeChecked
> class Base {
>     private String z = 'x'
>     static class Sub extends Base {}
>     class Inner {
>         def m(Sub sub) { sub.z }
>     }
>     def t() { new Inner().m(new Sub()) }
> }
> new Base().t()
> {code}
> Actual: all three compile and then fail with MissingPropertyException: No 
> such property: z for class: E$1 (or Base$Sub).
> Expected: compile errors "No such property: z for class: ...", as for the 
> shapes GROOVY-12610 covers. Under @CompileStatic all three keep compiling, 
> since static compilation accesses the field directly.
> Cause: ClassNodeUtils.hasNoEnclosingInstance returned false for an enum 
> constant body, which is created in the enum's static initializer. The type 
> checker also did not take two run-time limits into account: there is no 
> enclosing-instance fallback for a write through super (GROOVY-11823), and the 
> fallback applies only when the receiver is an instance of the calling class.
> The enum case is seen in 4.0.33, 5.0.8 and 6.0.0.
> PR: https://github.com/apache/groovy/pull/3147



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

Reply via email to