Howard created GROOVY-9861:
------------------------------

             Summary: 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
            Reporter: Howard


The follow code compiles fine under groovy 2 but does not compile under groovy 3
{code}
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}
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}
            if(isAprilFools) {
                clickCount++;
            }
{code}

if you just have
{code}
if(isAprilFools) { 
  println(1) 
}

// or just
clickCount++;

// but when you add clickCount++ into the if statement, it fails
{code}




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

Reply via email to