Chris Briem created GROOVY-11816:
------------------------------------
Summary: General error during instruction selection: out-of-scope
static check
Key: GROOVY-11816
URL: https://issues.apache.org/jira/browse/GROOVY-11816
Project: Groovy
Issue Type: Bug
Components: Compiler
Affects Versions: 5.0.3, 5.0.2, 5.0.1
Reporter: Chris Briem
The following snippet does not compile in Groovy 5:
{code:groovy}
package org.apache.groovy;
import groovy.transform.CompileStatic
@CompileStatic
class TestClass {
List<Class<?>> classes
def doIt() {
println("${classes*.simpleName}")
}
}
{code}
I get the following error:
{noformat}
Execution failed for task ':compileGroovy'.
> Unrecoverable compilation error: startup failed:
General error during instruction selection: out-of-scope static check
java.lang.IllegalStateException: out-of-scope static check
at
org.codehaus.groovy.classgen.asm.WriterController.isStaticContext(WriterController.java:322)
at
org.codehaus.groovy.classgen.asm.DelegatingController.isStaticContext(DelegatingController.java:235)
at
org.codehaus.groovy.classgen.AsmClassGenerator.isStatic(AsmClassGenerator.java:1222)
at
org.codehaus.groovy.classgen.AsmClassGenerator.visitPropertyExpression(AsmClassGenerator.java:1250)
at
org.codehaus.groovy.ast.expr.PropertyExpression.visit(PropertyExpression.java:63)
at
org.codehaus.groovy.classgen.AsmClassGenerator.visitVariableExpression(AsmClassGenerator.java:1469)
at
org.codehaus.groovy.ast.expr.VariableExpression.visit(VariableExpression.java:243)
at
org.codehaus.groovy.classgen.asm.ExpressionAsVariableSlot.visit(ExpressionAsVariableSlot.java:54)
at
org.codehaus.groovy.classgen.AsmClassGenerator.visitBytecodeExpression(AsmClassGenerator.java:1955)
at
org.codehaus.groovy.classgen.BytecodeExpression.visit(BytecodeExpression.java:55)
at
org.codehaus.groovy.classgen.asm.sc.StaticInvocationWriter.makeCall(StaticInvocationWriter.java:579)
at
org.codehaus.groovy.classgen.asm.InvocationWriter.writeInvokeMethod(InvocationWriter.java:501)
[..]
{noformat}
It used to work with Groovy 4.x and earlier. If I remove the
{{@CompileStatic}}, it works.
I have committed a full reproducer to GitHub:
https://github.com/chbriem/groovy-reproducer
--
This message was sent by Atlassian Jira
(v8.20.10#820010)