[
https://issues.apache.org/jira/browse/GROOVY-12084?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18088398#comment-18088398
]
ASF GitHub Bot commented on GROOVY-12084:
-----------------------------------------
paulk-asert opened a new pull request, #2605:
URL: https://github.com/apache/groovy/pull/2605
…nvariant but no @Requires throws ClassCastException (SynchronizedStatement
→ BlockStatement)
> groovy-contracts: @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
> Components: groovy-contracts
> 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)