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

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

codeconsole commented on PR #3114:
URL: https://github.com/apache/groovy/pull/3114#issuecomment-7072822796

   @daniellansun Thanks for re-checking. I merged current master (ca71425976) 
in d5c59a51e7, which clears the conflict. Master's GROOVY-12592 change (#3118) 
now carries a broader version of the `MopWriter` code from 3e74e8bf33: it also 
covers plain `super` in closures. So `MopWriter.java` here is now identical to 
master and has dropped out of this diff. The rest of #3049 is still stacked 
here until it lands. #3049 needs the same `MopWriter` resolution against master 
first, and after that a master merge here leaves only the GROOVY-12589 commits: 
94de9dc10f (the `superReceiver` handling in 
`StaticTypeCheckingVisitor.existsProperty`), f0de2de526 and 2ae91fe259. A 
correction to my 2026-11-08 comment: no COMPATIBILITY.md change is left in this 
PR or in #3049.




> SC: super.name within a class nested in its superclass calls the wrong 
> accessor or throws MissingPropertyException
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12589
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12589
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 4.0.33, 5.0.8, 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> {code:groovy}
> import groovy.transform.*
> class Base {
>     boolean f
>     boolean isF() { true }
>     boolean getF() { false }
>     @CompileStatic
>     static class Sub extends Base {
>         boolean isF() { false }
>         boolean getF() { true }
>         def plain() { super.f }
>         def test() { def c = { -> super.f }; c() }
>     }
> }
> assert new Base.Sub().plain()
> assert new Base.Sub().test()
> {code}
> Actual: groovy.lang.MissingPropertyException: No such property: f for class: 
> Base$Sub, for both methods. If Sub overrides only isF, both return the result 
> of Base.getF instead. The same happens for any property whose getter Sub 
> overrides (for example String x with getX), and assigning super.x in a 
> closure throws VerifyError.
> Expected: both assertions pass. Base.isF is called, as in dynamic Groovy.
> Within a class nested in its superclass, the type checker resolves super.f as 
> the superclass field that the nested class may access, so it records no 
> accessor and requests no super$ helper, and static compilation falls back to 
> a dynamic getPropertyOnSuper call. That call cannot reach the overridden 
> accessors of a statically compiled class, which has no MOP methods. A plain 
> subclass that is not nested in its superclass is not affected.
> Seen in 4.0.33, 5.0.8, 6.0.0 and master. With PR #3049 (GROOVY-12518) the 
> plain super.f works and only the closure and lambda forms fail.
> PR: https://github.com/apache/groovy/pull/3114



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

Reply via email to