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

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

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

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




> SC: a private field of the outer class referenced by its bare name in a class 
> nested in a static nested subclass throws VerifyError
> -----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12600
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12600
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 5.0.8, 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> {code:groovy}
> class Base {
>     private String z = 'x'
>     @groovy.transform.CompileStatic
>     static class Sub extends Base {
>         def m() { z }
>     }
> }
> assert new Base.Sub().m() == 'x'
> {code}
> Actual: the class fails verification when loaded:
> {noformat}
> java.lang.VerifyError: Bad type on operand stack
>   Location: Base$Sub.m()Ljava/lang/Object; @1: invokevirtual
>   Reason: Type 'Base$Sub' (current frame, stack[0]) is not assignable to 
> 'groovy/lang/Closure'
> {noformat}
> The same happens for assignment, compound assignment and increment of the 
> bare name, inside closures and lambdas, in an anonymous class within the 
> subclass, and for a non-static inner subclass of a static nested class.
> Expected: {{m()}} returns 'x', the field the subclass inherits, as {{this.z}} 
> and {{super.z}} already do under static compilation.
> Cause: the type checker resolves the name to the inherited field as a 
> nestmate private access, but the static compilation transformer always 
> rewrites it to {{Base.this.@z}}. The subclass has no enclosing Base instance, 
> so the class generator falls back to the closure path and emits 
> {{Closure.getThisObject()}} on a non-closure.
> Seen in 5.0.8 and 6.0.0. 4.0.33 compiles it to a dynamic access that throws 
> MissingPropertyException.
> PR: https://github.com/apache/groovy/pull/3127



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

Reply via email to