Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
The following program
import java.util.function.Function; import java.util.function.Supplier; abstract class Test { void test() { Supplier<Long> keystone = () -> { Closure<Long> inner = (Object evolve, Supplier<Integer> x) -> null inner(new Object(), new B()::m).f } } } class A { Long f } class B { Integer m() {1} }
produces a crash with the following stack trace
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: General error during canonicalization: Index 1 out of bounds for length 1 java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1 at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.inferMethodReferenceType(StaticTypeCheckingVisitor.java:3629) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallArguments(StaticTypeCheckingVisitor.java:2807) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallExpression(StaticTypeCheckingVisitor.java:3563) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethodCallExpression(StaticCompilationVisitor.java:414) at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:77) at org.codehaus.groovy.ast.CodeVisitorSupport.visitPropertyExpression(CodeVisitorSupport.java:340) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.existsProperty(StaticTypeCheckingVisitor.java:1475) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.existsProperty(StaticCompilationVisitor.java:550) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.existsProperty(StaticTypeCheckingVisitor.java:1462) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitPropertyExpression(StaticTypeCheckingVisitor.java:720) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitPropertyExpression(StaticCompilationVisitor.java:565) at org.codehaus.groovy.ast.expr.PropertyExpression.visit(PropertyExpression.java:63) at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:117) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:204) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitExpressionStatement(StaticTypeCheckingVisitor.java:2191) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:86) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:168) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitBlockStatement(StaticTypeCheckingVisitor.java:3931) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:70) at org.codehaus.groovy.ast.CodeVisitorSupport.visitClosureExpression(CodeVisitorSupport.java:239) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitClosureExpression(StaticTypeCheckingVisitor.java:2403) at org.codehaus.groovy.ast.CodeVisitorSupport.visitLambdaExpression(CodeVisitorSupport.java:244) at org.codehaus.groovy.ast.expr.LambdaExpression.visit(LambdaExpression.java:46) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitBinaryExpression(StaticTypeCheckingVisitor.java:791) at org.codehaus.groovy.ast.CodeVisitorSupport.visitDeclarationExpression(CodeVisitorSupport.java:335) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitDeclarationExpression(ClassCodeVisitorSupport.java:154) at org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:89) at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:117) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:204) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitExpressionStatement(StaticTypeCheckingVisitor.java:2191) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:86) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:168) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitBlockStatement(StaticTypeCheckingVisitor.java:3931) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:70) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:142) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:115) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitConstructorOrMethod(StaticTypeCheckingVisitor.java:2597) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:110) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.startMethodInference(StaticTypeCheckingVisitor.java:2586) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethod(StaticTypeCheckingVisitor.java:2560) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethod(StaticCompilationVisitor.java:239) at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1134) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1127) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitClass(StaticTypeCheckingVisitor.java:438) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitClass(StaticCompilationVisitor.java:197) at org.codehaus.groovy.transform.sc.StaticCompileTransformation.visit(StaticCompileTransformation.java:68) at org.codehaus.groovy.control.customizers.ASTTransformationCustomizer.call(ASTTransformationCustomizer.groovy:298) at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:911) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:653) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:630) 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) 1 error
Tested against master (https://github.com/apache/groovy/commit/22955a57b4972f32408824d20fc554c9d40e3291)
Attachments
Issue Links
- relates to
-
GROOVY-10979 Cannot provide method reference to a type parameter instantiated with a SAM type
- Open