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

Eric Milles resolved GROOVY-7295.
---------------------------------
    Resolution: Fixed

> ConfigObject instance can't be coerced into trait in runtime
> ------------------------------------------------------------
>
>                 Key: GROOVY-7295
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7295
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.4.0
>            Reporter: Pavel Alexeev
>            Priority: Major
>              Labels: trait, traits
>
> It works with other classes, even Java (Integer for example):
> {code}
> trait Extra {
>     String extra() { "I'm an extra method" }
> }
> class Something {
>     String doSomething() { 'Something' }
> }
> def s = new Something() as Extra;
> assert "I'm an extra method" == s.extra()
> assert 'Something' == s.doSomething()
> def i = new Integer(0) as Extra;
> assert "I'm an extra method" == i.extra()
> def conf = new ConfigSlurper().parse('some = 7')
> // Uncomment it and you are receive error:
> // def ss = conf as Extra
> /*
> java.lang.NoClassDefFoundError: Extra
>     at ConsoleScript24.run(ConsoleScript24:16)
> Caused by: java.lang.ClassNotFoundException: Extra
>     ... 1 more
> */
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to