Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4.3
-
None
Description
This source:
@groovy.transform.CompileStatic def myMethod(String a, String b) { assert [a, b]*.size() == [5, 5] } myMethod('hello', 'world')
Results in this compile error:
BUG! exception in phase 'class generation' in source unit 'ConsoleScript1' In method public java.lang.Object MyMethod(java.lang.String a, java.lang.String b) { ... }, CompileStack#removeVar: tried to remove a temporary variable with index 3 in wrong order. Current temporary variables=[iterator(index=6,type=java.util.Iterator <E extends java.lang.Object -> java.lang.Object>,holder=false), recorder(index=3,type=java.lang.Object,holder=false)] at org.codehaus.groovy.classgen.asm.CompileStack.removeVar(CompileStack.java:226) at org.codehaus.groovy.classgen.asm.AssertionWriter.writeAssertStatement(AssertionWriter.java:136) at org.codehaus.groovy.classgen.asm.StatementWriter.writeAssert(StatementWriter.java:550) at org.codehaus.groovy.classgen.AsmClassGenerator.visitAssertStatement(AsmClassGenerator.java:587) */
but this compiles and runs fine:
@groovy.transform.CompileStatic def myMethod(String a, String b) { def result = [a, b]*.size() assert result == [5, 5] } myMethod('hello', 'world')