You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Simon Rehm (Jira)" <ji...@apache.org> on 2020/12/22 16:16:00 UTC

[jira] [Created] (GROOVY-9872) GroovyCastException when iterating over something in the constructor of a @CompileStatic object

Simon Rehm created GROOVY-9872:
----------------------------------

             Summary: GroovyCastException when iterating over something in the constructor of a @CompileStatic object
                 Key: GROOVY-9872
                 URL: https://issues.apache.org/jira/browse/GROOVY-9872
             Project: Groovy
          Issue Type: Bug
          Components: groovy-jdk
    Affects Versions: 2.5.14
            Reporter: Simon Rehm


This odd code works fine in 2.5.13, but explodes in 2.5.14. 
My workaround for now is to remove @CompileStatic in production.

Minimal example (spock test):
{{}}
{code:java}
import groovy.transform.CompileStatic
import spock.lang.Specification

class FooTest extends Specification {
    def "test"() {
        when:
        new Foo()

        then:
        noExceptionThrown()
    }
}

@CompileStatic
class Foo {
    private Map<String, String> cache = [:]
    Foo() {
        [''].each {
            cache[''] = ''
        }
    }
}{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)