Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.3.0-beta-1
-
None
-
None
Description
Sorry for the vague summary. The following doesn't compileâ¦
import groovy.transform.CompileStatic interface Transform<T> { T transform(T input) } class Holder<T> { final T thing Holder(T thing) { this.thing = thing } T transform(Transform<T> transform) { transform.transform(thing) } } @CompileStatic class Container { static void m() { def holder = new Holder<Integer>(2) def transformed = holder.transform { it * 2 } assert transformed == 4 } }
The problem seems to be the holder.transform() call. This code works without @CompileStatic.
In GroovyConsole I get:
java.lang.InstantiationException: Transform
In IDEA 13.1.1 I get:
Error:Groovyc: A groovyc error occurred while trying to load one of the classes in project dependencies, please ensure it's present. See the message and the stack trace below for reference java.lang.ClassCircularityError: Transform at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:270) at groovy.transform.stc.ClosureSignatureHint.findClassNode(ClosureSignatureHint.java:133) at groovy.transform.stc.FromAbstractTypeMethods.getClosureSignatures(FromAbstractTypeMethods.java:41) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.doInferClosureParameterTypes(StaticTypeCheckingVisitor.java:2012) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.inferClosureParameterTypes(StaticTypeCheckingVisitor.java:2000) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallArguments(StaticTypeCheckingVisitor.java:1965) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallExpression(StaticTypeCheckingVisitor.java:2501) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethodCallExpression(StaticCompilationVisitor.java:245) at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:64) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitBinaryExpression(StaticTypeCheckingVisitor.java:432) at org.codehaus.groovy.ast.CodeVisitorSupport.visitDeclarationExpression(CodeVisitorSupport.java:245) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitDeclarationExpression(ClassCodeVisitorSupport.java:107) at org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:86) at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:69) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:193) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:35) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:163) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:101) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:112) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitConstructorOrMethod(StaticTypeCheckingVisitor.java:1501) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:123) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.startMethodInference(StaticTypeCheckingVisitor.java:1789) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethod(StaticTypeCheckingVisitor.java:1762) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethod(StaticCompilationVisitor.java:144) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1063) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitClass(StaticTypeCheckingVisitor.java:173) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitClass(StaticCompilationVisitor.java:110) at org.codehaus.groovy.transform.sc.StaticCompileTransformation.visit(StaticCompileTransformation.java:61) at org.codehaus.groovy.transform.ASTTransformationVisitor.visitClass(ASTTransformationVisitor.java:132) at org.codehaus.groovy.transform.ASTTransformationVisitor$2.call(ASTTransformationVisitor.java:176) at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1047) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:583) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:561) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:538) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:286) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:259) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:245) at groovy.lang.GroovyClassLoader.recompile(GroovyClassLoader.java:739) at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:696) at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:765) at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:753) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:270) at groovy.transform.stc.ClosureSignatureHint.findClassNode(ClosureSignatureHint.java:133) at groovy.transform.stc.FromAbstractTypeMethods.getClosureSignatures(FromAbstractTypeMethods.java:41) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.doInferClosureParameterTypes(StaticTypeCheckingVisitor.java:2012) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.inferClosureParameterTypes(StaticTypeCheckingVisitor.java:2000) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallArguments(StaticTypeCheckingVisitor.java:1965) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallExpression(StaticTypeCheckingVisitor.java:2501) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethodCallExpression(StaticCompilationVisitor.java:245) at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:64) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitBinaryExpression(StaticTypeCheckingVisitor.java:432) at org.codehaus.groovy.ast.CodeVisitorSupport.visitDeclarationExpression(CodeVisitorSupport.java:245) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitDeclarationExpression(ClassCodeVisitorSupport.java:107) at org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:86) at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:69) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:193) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:35) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:163) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:101) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:112) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitConstructorOrMethod(StaticTypeCheckingVisitor.java:1501) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:123) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.startMethodInference(StaticTypeCheckingVisitor.java:1789) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethod(StaticTypeCheckingVisitor.java:1762) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethod(StaticCompilationVisitor.java:144) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1063) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitClass(StaticTypeCheckingVisitor.java:173) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitClass(StaticCompilationVisitor.java:110) at org.codehaus.groovy.transform.sc.StaticCompileTransformation.visit(StaticCompileTransformation.java:61) at org.codehaus.groovy.transform.ASTTransformationVisitor.visitClass(ASTTransformationVisitor.java:132) at org.codehaus.groovy.transform.ASTTransformationVisitor$2.call(ASTTransformationVisitor.java:176) at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1047) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:583) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:561) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:538) at org.jetbrains.groovy.compiler.rt.GroovyCompilerWrapper.compile(GroovyCompilerWrapper.java:54) at org.jetbrains.groovy.compiler.rt.DependentGroovycRunner.runGroovyc(DependentGroovycRunner.java:81) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.jetbrains.groovy.compiler.rt.GroovycRunner.main(GroovycRunner.java:100) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:121)