[
https://issues.apache.org/jira/browse/GROOVY-12084?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Paul King updated GROOVY-12084:
-------------------------------
Description:
This code:
{code:groovy}
import groovy.contracts.*
class A {
@groovy.transform.Synchronized
//@Requires({ a >= 0 })
@Ensures({ a >= 0 })
def m(int a) { return a}
}
def a = new A()
a.m(12)
{code}
Gives this error:
{noformat}
Exception thrown
BUG! exception in phase 'instruction selection' in source unit 'ConsoleScript6'
class org.codehaus.groovy.ast.stmt.SynchronizedStatement cannot be cast to
class org.codehaus.groovy.ast.stmt.BlockStatement
(org.codehaus.groovy.ast.stmt.SynchronizedStatement and
org.codehaus.groovy.ast.stmt.BlockStatement are in unnamed module of loader
org.codehaus.groovy.tools.RootLoader @6e0be858)
at
org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:980)
...
{noformat}
It runs fine if the @Requires is present.
> @Synchronized method with @Ensures/@Invariant but no @Requires throws
> ClassCastException (SynchronizedStatement → BlockStatement)
> ---------------------------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12084
> URL: https://issues.apache.org/jira/browse/GROOVY-12084
> Project: Groovy
> Issue Type: Bug
> Reporter: Paul King
> Assignee: Paul King
> Priority: Major
>
> This code:
> {code:groovy}
> import groovy.contracts.*
> class A {
> @groovy.transform.Synchronized
> //@Requires({ a >= 0 })
> @Ensures({ a >= 0 })
> def m(int a) { return a}
> }
> def a = new A()
> a.m(12)
> {code}
> Gives this error:
> {noformat}
> Exception thrown
> BUG! exception in phase 'instruction selection' in source unit
> 'ConsoleScript6' class org.codehaus.groovy.ast.stmt.SynchronizedStatement
> cannot be cast to class org.codehaus.groovy.ast.stmt.BlockStatement
> (org.codehaus.groovy.ast.stmt.SynchronizedStatement and
> org.codehaus.groovy.ast.stmt.BlockStatement are in unnamed module of loader
> org.codehaus.groovy.tools.RootLoader @6e0be858)
> at
> org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:980)
> ...
> {noformat}
> It runs fine if the @Requires is present.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)