Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
I have the following well-typed program:
interface TemporalQuery<T1> { T1 queryFrom(TemporalAccessor p0); } class TemporalAccessor {} class Test { void test() { TemporalQuery<String> rec = null; TemporalQuery<String> gravy = rec::queryFrom; } }
The program crashes the compiler and produces the following stack trace
>>> a serious error occurred: BUG! exception in phase 'class generation' in source unit 'Main.groovy' ClassNode#getTypeClass for Foo called before the type class is set >>> stacktrace: BUG! exception in phase 'class generation' in source unit 'Main.groovy' ClassNode#getTypeClass for Foo called before the type class is set at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1357) at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1351) at org.codehaus.groovy.classgen.asm.sc.AbstractFunctionalInterfaceWriter.lambda$createMethodDescriptor$0(AbstractFunctionalInterfaceWriter.java:49) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575) at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260) at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616) at org.codehaus.groovy.classgen.asm.sc.AbstractFunctionalInterfaceWriter.createMethodDescriptor(AbstractFunctionalInterfaceWriter.java:49) at org.codehaus.groovy.classgen.asm.sc.StaticTypesMethodReferenceExpressionWriter.writeMethodReferenceExpression(StaticTypesMethodReferenceExpressionWriter.java:176) at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodReferenceExpression(AsmClassGenerator.java:935) at org.codehaus.groovy.ast.expr.MethodReferenceExpression.visit(MethodReferenceExpression.java:34) at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluateEqual(BinaryExpressionHelper.java:423) at org.codehaus.groovy.classgen.asm.sc.StaticTypesBinaryExpressionMultiTypeDispatcher.evaluateEqual(StaticTypesBinaryExpressionMultiTypeDispatcher.java:203) at org.codehaus.groovy.classgen.AsmClassGenerator.visitDeclarationExpression(AsmClassGenerator.java:853) at org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:92) at org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:610) at org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:837) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41) at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:86) at org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeBlockStatement(StaticTypesStatementWriter.java:77) at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:762) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:72) at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:621) at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:556) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:110) at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:705) at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1278) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1271) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52) at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:367) at org.codehaus.groovy.control.CompilationUnit$4.call(CompilationUnit.java:810) at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:952) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:698) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:672) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:653) at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:312) at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:241) at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:166) at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:206) at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:190)
Tested against master (commit: 4c10bc8ad43a9dc015be374889adb2e967412afc)