groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (GROOVY-7442) spread operator within assert isn't expected with @CompileStatic
Date Mon, 01 Jun 2015 09:47:18 GMT

     [ https://issues.apache.org/jira/browse/GROOVY-7442?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Paul King updated GROOVY-7442:
------------------------------
    Summary: spread operator within assert isn't expected with @CompileStatic  (was: spread
operator within assert isn't expected)

> spread operator within assert isn't expected with @CompileStatic
> ----------------------------------------------------------------
>
>                 Key: GROOVY-7442
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7442
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Paul King
>
> This source:
> {code}
> @groovy.transform.CompileStatic
> def myMethod(String a, String b) {
>   assert [a, b]*.size() == [5, 5]
> }
> myMethod('hello', 'world')
> {code}
> Results in this compile error:
> {noformat}
> 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)
> */
> {noformat}
> but this compiles and runs fine:
> {code}
> @groovy.transform.CompileStatic
> def myMethod(String a, String b) {
>   def result = [a, b]*.size()
>   assert result == [5, 5]
> }
> myMethod('hello', 'world')
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message