You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2024/10/01 16:22:00 UTC
[jira] [Updated] (GROOVY-11487) RuntimeParserException when encountering a lambda and a function type with wildcard
[ https://issues.apache.org/jira/browse/GROOVY-11487?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles updated GROOVY-11487:
---------------------------------
Language: groovy
> RuntimeParserException when encountering a lambda and a function type with wildcard
> -----------------------------------------------------------------------------------
>
> Key: GROOVY-11487
> URL: https://issues.apache.org/jira/browse/GROOVY-11487
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Reporter: Thodoris Sotiropoulos
> Priority: Minor
>
> I have the following program
>
> {code:java}
> import java.util.function.Function;
> interface A<T> {}
> interface B<T> extends A<String> {}
> class Test {
> final Function<? super B<String>, String> test() {
> return (A<String> x) -> ""
> }
> } {code}
> h3.
> Actual behavior
> The compiler crashes with
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> General error during instruction selection: The inferred type[B<T>] is not compatible with the parameter type[A<T>]
> . At [9:13] test.groovyorg.codehaus.groovy.syntax.RuntimeParserException: The inferred type[B<T>] is not compatible with the parameter type[A<T>]
> . At [9:13] test.groovy
> at org.codehaus.groovy.classgen.asm.sc.AbstractFunctionalInterfaceWriter.convertParameterType(AbstractFunctionalInterfaceWriter.java:134)
> at org.codehaus.groovy.classgen.asm.sc.StaticTypesLambdaWriter.createParametersWithExactType(StaticTypesLambdaWriter.java:297)
> at org.codehaus.groovy.classgen.asm.sc.StaticTypesLambdaWriter.addSyntheticLambdaMethodNode(StaticTypesLambdaWriter.java:274)
> at org.codehaus.groovy.classgen.asm.sc.StaticTypesLambdaWriter.createLambdaClass(StaticTypesLambdaWriter.java:251)
> at org.codehaus.groovy.classgen.asm.sc.StaticTypesLambdaWriter.lambda$getOrAddLambdaClass$2(StaticTypesLambdaWriter.java:216)
> at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1228)
> at org.codehaus.groovy.classgen.asm.sc.StaticTypesLambdaWriter.getOrAddLambdaClass(StaticTypesLambdaWriter.java:215)
> at org.codehaus.groovy.classgen.asm.sc.StaticTypesLambdaWriter.writeLambda(StaticTypesLambdaWriter.java:118)
> at org.codehaus.groovy.classgen.AsmClassGenerator.visitLambdaExpression(AsmClassGenerator.java:873)
> at org.codehaus.groovy.ast.expr.LambdaExpression.visit(LambdaExpression.java:46)
> at org.codehaus.groovy.classgen.asm.StatementWriter.writeReturn(StatementWriter.java:591)
> at org.codehaus.groovy.classgen.AsmClassGenerator.visitReturnStatement(AsmClassGenerator.java:822)
> at org.codehaus.groovy.ast.stmt.ReturnStatement.visit(ReturnStatement.java:73)
> at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:95)
> at org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeBlockStatement(StaticTypesStatementWriter.java:77)
> at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:752)
> at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:72)
> at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:611)
> at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:546)
> at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:110)
> at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:695)
> at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1132)
> at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1125)
> at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52)
> at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:365)
> at org.codehaus.groovy.control.CompilationUnit$3.call(CompilationUnit.java:797)
> at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:938)
> at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:692)
> at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:666)
> at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:647)
> 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)
> at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
> at java.base/java.lang.reflect.Method.invoke(Method.java:580)
> at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:115)
> at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:37)1 error
> {code}
> h3.
> Notes
> Tested against master (commit: aa298337dadd8a10053897e397cd83377127ca27)
--
This message was sent by Atlassian Jira
(v8.20.10#820010)