Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
The following program
class Foo { protected Foo(Closure<Foo, Bar> 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); } } }
crashes the compiler with a NullPointerException
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
Tested against https://github.com/apache/groovy/commit/e64215983ea4b7c277eb01a1ed3fcac43976be9c