groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mauro Molinari (JIRA)" <>
Subject [jira] [Created] (GROOVY-8873) Fails at runtime with @CompileStatic and two nested with
Date Fri, 09 Nov 2018 11:58:00 GMT
Mauro Molinari created GROOVY-8873:

             Summary: Fails at runtime with @CompileStatic and two nested with
                 Key: GROOVY-8873
             Project: Groovy
          Issue Type: Bug
          Components: Static compilation
    Affects Versions: 2.5.3, 2.4.15
            Reporter: Mauro Molinari

Consider this class:
package testgroovy

import groovy.transform.CompileStatic

class Foobar {
    static class Foo {
        String aaa = 'aaa'
        String bbb = 'bbb'
    static class Bar {
        String ccc = 'ccc'
    Foo foo = new Foo()
    Bar bar = new Bar()
    void foobar() {
        foo.with {
            bar.with {
                println aaa
                println bbb
                println ccc

    static void main(String[] args) {
        new Foobar().foobar()
It fails at runtime with:
Exception in thread "main" java.lang.ClassCastException: testgroovy.Foobar$Bar cannot be cast
to groovy.lang.Closure
    at testgroovy.Foobar$_foobar_closure1$_closure2.doCall(Foobar.groovy:23)
    at testgroovy.Foobar$_foobar_closure1$
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.with(
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.with(
    at testgroovy.Foobar$_foobar_closure1.doCall(Foobar.groovy:22)
    at testgroovy.Foobar$
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.with(
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.with(
    at testgroovy.Foobar.foobar(Foobar.groovy:21)
    at testgroovy.Foobar.main(Foobar.groovy:31){noformat}
It works fine if you remove {{@CompileStatic}}.

This message was sent by Atlassian JIRA

View raw message