[ 
https://issues.apache.org/jira/browse/GROOVY-9861?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Eric Milles resolved GROOVY-9861.
---------------------------------
    Fix Version/s: 4.0.0-alpha-3
       Resolution: Fixed

Fixed by GROOVY-9892

> parsing bug when inner class references top level class fields in groovy 3
> --------------------------------------------------------------------------
>
>                 Key: GROOVY-9861
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9861
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 3.0.6, 3.0.7
>            Reporter: Howard
>            Priority: Major
>             Fix For: 4.0.0-alpha-3
>
>
> The follow code compiles fine under groovy 2 but does not compile under 
> groovy 3
> {code:java}
> import groovy.transform.CompileStatic
> import java.awt.Color
> import java.awt.event.MouseAdapter
> import java.awt.event.MouseEvent
> @CompileStatic
> public class TreePair2 {
>     int clickCount = 0;
>     boolean isAprilFools = false;
>     private TreePair2() {
>     }
>     protected class TreeMouseClickHandler extends MouseAdapter {
>         @Override
>         public void mouseClicked(MouseEvent e) {
>             if(isAprilFools) {
>                 clickCount++;
>             }
>         }
>     }
> }
> {code}
> Error msg:
> {code:java}
> Exception thrown
> groovy.lang.GroovyRuntimeException: ASM reporting processing error for 
> TreePair2$TreeMouseClickHandler#mouseClicked with signature void 
> mouseClicked(java.awt.event.MouseEvent) in ConsoleScript77:18. ConsoleScript77
>       at jdk.internal.reflect.GeneratedMethodAccessor56.invoke(Unknown Source)
>       at 
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds 
> for length 0
>       at groovyjarjarasm.asm.Frame.merge(Frame.java:1268)
>       at groovyjarjarasm.asm.Frame.merge(Frame.java:1244)
>       at 
> groovyjarjarasm.asm.MethodWriter.computeAllFrames(MethodWriter.java:1610)
>       at groovyjarjarasm.asm.MethodWriter.visitMaxs(MethodWriter.java:1546)
>       ... 2 more{code}
> The problem seems to be with these 3 lines
> {code:java}
>             if(isAprilFools) {
>                 clickCount++;
>             }
> {code}
> if you just have
> {code:java}
> if(isAprilFools) { 
>   println(1) 
> }
> // it works
> // or just
> clickCount++;
> // also works
> // but when you add clickCount++ into the if statement, it fails
> {code}
> I also want to note that by removing staticcompilation, it seems to work.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to