You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Thodoris Sotiropoulos (Jira)" <ji...@apache.org> on 2021/04/12 11:57:00 UTC

[jira] [Created] (GROOVY-10033) Compiler crash when encountering function reference on nested class

Thodoris Sotiropoulos created GROOVY-10033:
----------------------------------------------

             Summary: Compiler crash when encountering function reference on nested class
                 Key: GROOVY-10033
                 URL: https://issues.apache.org/jira/browse/GROOVY-10033
             Project: Groovy
          Issue Type: Bug
          Components: Static compilation
            Reporter: Thodoris Sotiropoulos


The following program

 
{code:java}
class Foo {
  protected Foo(Closure x) {}
}

class Bar {
    Bar(Foo x) {}
}

public class X extends Foo {
    public X() {
        super(Y::new);
    }

    private class Y extends Bar {
        Y(Foo x) {
            super(x);
        }
    }
}
{code}
 

crashes the compiler with a NullPointerException
{code:java}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
General error during instruction selection: NullPointerException while processing test.groovy. test.groovygroovy.lang.GroovyRuntimeException: NullPointerException while processing test.groovy. test.groovy
        at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:348)
        at org.codehaus.groovy.control.CompilationUnit$3.call(CompilationUnit.java:783)
        at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:928)
        at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:657)
        at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:634)
        at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:609)
        at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:311)
        at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:240)
        at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:165)
        at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:205)
        at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:189)
Caused by: java.lang.NullPointerException
        at org.codehaus.groovy.classgen.asm.sc.StaticTypesMethodReferenceExpressionWriter.createParametersWithExactType(StaticTypesMethodReferenceExpressionWriter.java:255)
        at org.codehaus.groovy.classgen.asm.sc.StaticTypesMethodReferenceExpressionWriter.writeMethodReferenceExpression(StaticTypesMethodReferenceExpressionWriter.java:97)
        at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodReferenceExpression(AsmClassGenerator.java:844)
        at org.codehaus.groovy.ast.expr.MethodReferenceExpression.visit(MethodReferenceExpression.java:34)
        at org.codehaus.groovy.classgen.asm.sc.StaticInvocationWriter.visitArgument(StaticInvocationWriter.java:517)
        at org.codehaus.groovy.classgen.asm.sc.StaticInvocationWriter.loadArguments(StaticInvocationWriter.java:464)
        at org.codehaus.groovy.classgen.asm.sc.StaticInvocationWriter.writeSpecialConstructorCall(StaticInvocationWriter.java:212)
        at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorCallExpression(AsmClassGenerator.java:917)
        at org.codehaus.groovy.ast.expr.ConstructorCallExpression.visit(ConstructorCallExpression.java:45)
        at org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:602)
        at org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:744)
        at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41)
        at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:92)
        at org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeBlockStatement(StaticTypesStatementWriter.java:78)
        at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:675)
        at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:70)
        at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:516)
        at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:461)
        at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructor(ClassCodeVisitorSupport.java:101)
        at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructor(AsmClassGenerator.java:608)
        at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1097)
        at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52)
        at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:325)
        ... 10 more1 error

{code}
Tested against https://github.com/apache/groovy/commit/e64215983ea4b7c277eb01a1ed3fcac43976be9c

 



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