You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2019/01/21 05:35:00 UTC
[jira] [Resolved] (GROOVY-8873) Fails at runtime with
@CompileStatic and two nested with
[ https://issues.apache.org/jira/browse/GROOVY-8873?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King resolved GROOVY-8873.
-------------------------------
Resolution: Fixed
Assignee: Paul King
Fix Version/s: 3.0.0-alpha-5
2.5.6
Proposed PR merged.
> 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)