[
https://issues.apache.org/jira/browse/GROOVY-12172?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Adrien Guichard updated GROOVY-12172:
-------------------------------------
Summary: Groovy 5.0.7 fails to compile or startup with
UnsupportedOperationException (was: Groovy 5.0.7 fail to compile or startup
with UnsupportedOperationException)
> Groovy 5.0.7 fails to compile or startup with UnsupportedOperationException
> ---------------------------------------------------------------------------
>
> Key: GROOVY-12172
> URL: https://issues.apache.org/jira/browse/GROOVY-12172
> Project: Groovy
> Issue Type: Bug
> Components: build
> Affects Versions: 5.0.7
> Reporter: Adrien Guichard
> Priority: Minor
>
> When compiling the following code:
> {code:java}
> import groovy.transform.CompileStatic
> @CompileStatic
> class X1 {
> Long id
> }
> @CompileStatic
> class X2 {
> Long id
> }
> @CompileStatic
> class Y {
> Long computeId(Object test) {
> if (test instanceof X1 || test instanceof X2) {
> return test['id'] as Long
> null
> }
> }
> }
> println new Y().computeId(new X1(id: 12))
> {code}
> Groovy 5.0.7 fails with MultipleCompilationErrorsException
> , but Groovy 4.0.32 is OK:
> {code:java}
> ~/dev/groovy
> ❯ ./groovy-4.0.32/bin/groovy test.groovy
> 12
> ~/dev/groovy
> ❯ ./groovy-5.0.7/bin/groovy test.groovy
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup
> failed:
> General error during instruction selection:
> java.lang.UnsupportedOperationException {code}
> It is not a code pattern we tend to use often, but on a huge code base, it
> can be tricky to narrow done this kind of issue.
> A simple workaround would be to split the if.
> Thanks for your support,
> Adrien
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)