groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <j...@apache.org>
Subject [jira] [Closed] (GROOVY-8873) Fails at runtime with @CompileStatic and two nested with
Date Thu, 21 Feb 2019 06:19:03 GMT

     [ https://issues.apache.org/jira/browse/GROOVY-8873?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Paul King closed GROOVY-8873.
-----------------------------

> Fails at runtime with @CompileStatic and two nested with
> --------------------------------------------------------
>
>                 Key: GROOVY-8873
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8873
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>    Affects Versions: 2.4.15, 2.5.3
>            Reporter: Mauro Molinari
>            Assignee: Paul King
>            Priority: Major
>             Fix For: 2.5.6, 3.0.0-alpha-5
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Consider this class:
> {code:java}
> package testgroovy
> import groovy.transform.CompileStatic
> @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()
>     }    
> }{code}
> It fails at runtime with:
> {noformat}
> 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$_closure2.call(Foobar.groovy)
>     at org.codehaus.groovy.runtime.DefaultGroovyMethods.with(DefaultGroovyMethods.java:369)
>     at org.codehaus.groovy.runtime.DefaultGroovyMethods.with(DefaultGroovyMethods.java:316)
>     at testgroovy.Foobar$_foobar_closure1.doCall(Foobar.groovy:22)
>     at testgroovy.Foobar$_foobar_closure1.call(Foobar.groovy)
>     at org.codehaus.groovy.runtime.DefaultGroovyMethods.with(DefaultGroovyMethods.java:369)
>     at org.codehaus.groovy.runtime.DefaultGroovyMethods.with(DefaultGroovyMethods.java:316)
>     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
(v7.6.3#76005)

Mime
View raw message