Thodoris Sotiropoulos created GROOVY-11873:
----------------------------------------------

             Summary: RuntimeParserException during instruction selection: the 
inferred type is not compatible with the parameter
                 Key: GROOVY-11873
                 URL: https://issues.apache.org/jira/browse/GROOVY-11873
             Project: Groovy
          Issue Type: Bug
            Reporter: Thodoris Sotiropoulos
             Fix For: 6.0.0-alpha-1


This test case crashes the compiler


{code:java}
public class Test {
  Function1<? super Short, ? extends Number> fun = (Long x) -> null;
}

interface Function1<A1, R> {
  R apply(A1 a1);
} {code}
 
{code:java}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
General error during instruction selection: The inferred type[java.lang.Short] 
is not compatible with the parameter type[java.lang.Long]
. At [2:53] Main.groovyorg.codehaus.groovy.syntax.RuntimeParserException: The 
inferred type[java.lang.Short] is not compatible with the parameter 
type[java.lang.Long]
. At [2:53] Main.groovy
    at 
org.codehaus.groovy.classgen.asm.sc.AbstractFunctionalInterfaceWriter.convertParameterType(AbstractFunctionalInterfaceWriter.java:114)
    at 
org.codehaus.groovy.classgen.asm.sc.StaticTypesLambdaWriter.createParametersWithExactType(StaticTypesLambdaWriter.java:297)
    at 
org.codehaus.groovy.classgen.asm.sc.StaticTypesLambdaWriter.addSyntheticLambdaMethodNode(StaticTypesLambdaWriter.java:273)
    at 
org.codehaus.groovy.classgen.asm.sc.StaticTypesLambdaWriter.createLambdaClass(StaticTypesLambdaWriter.java:253)
    at 
org.codehaus.groovy.classgen.asm.sc.StaticTypesLambdaWriter.lambda$getOrAddLambdaClass$2(StaticTypesLambdaWriter.java:219)
    at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1228)
    at 
org.codehaus.groovy.classgen.asm.sc.StaticTypesLambdaWriter.getOrAddLambdaClass(StaticTypesLambdaWriter.java:218)
    at 
org.codehaus.groovy.classgen.asm.sc.StaticTypesLambdaWriter.writeLambda(StaticTypesLambdaWriter.java:113)
    at 
org.codehaus.groovy.classgen.AsmClassGenerator.visitLambdaExpression(AsmClassGenerator.java:945)
    at 
org.codehaus.groovy.ast.expr.LambdaExpression.visit(LambdaExpression.java:46)
    at 
org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluateEqual(BinaryExpressionHelper.java:422)
    at 
org.codehaus.groovy.classgen.asm.sc.StaticTypesBinaryExpressionMultiTypeDispatcher.evaluateEqual(StaticTypesBinaryExpressionMultiTypeDispatcher.java:192)
    at 
org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.eval(BinaryExpressionHelper.java:164)
    at 
org.codehaus.groovy.classgen.AsmClassGenerator.visitBinaryExpression(AsmClassGenerator.java:921)
    at 
org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:57)
    at 
org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:662)
    at 
org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:899)
    at 
org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41)
    at 
org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:99)
    at 
org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeBlockStatement(StaticTypesStatementWriter.java:79)
    at 
org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:824)
    at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:72)
    at 
org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:684)
    at 
org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:619)
    at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructor(ClassCodeVisitorSupport.java:102)
    at 
org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructor(AsmClassGenerator.java:761)
    at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1325)
    at 
org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52)
    at 
org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:378)
    at 
org.codehaus.groovy.control.CompilationUnit$3.call(CompilationUnit.java:780)
    at 
org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:922)
    at 
org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:668)
    at 
org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:642)
    at 
org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:623)
    at 
org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:313)
    at 
org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:242)
    at 
org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:167)
    at 
org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:207)
    at 
org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:191)1 
error
 {code}
 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to