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

Eric Milles updated GROOVY-11142:
---------------------------------
    Labels: traits  (was: trait traits)

> this reference in trait fails to resolve properly 
> --------------------------------------------------
>
>                 Key: GROOVY-11142
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11142
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 3.0.18, 4.0.13
>            Reporter: Eric Milles
>            Priority: Major
>              Labels: traits
>
> Consider the following:
> {code:groovy}
> trait Foo {
>   void bar() {
>     print this
>   }
> }
> "xxx".withTraits(Foo).bar() // prints String1_groovyProxy@328cf0e1
> {code}
> {code:groovy}
> class Foo {
>   String toString() {
>     "foo"
>   }
> }
> trait Bar {
>   String getBaz() {
>     this.toString()
>   }
> }
> print(new Foo().withTraits(Bar).baz) // prints Foo2_groovyProxy@14b030a0
> {code}
> In the first example, I need to call a String method like 
> "this.toLowerCase()" instead of "this" for it to work.  I tried 
> "this.toStirng()" but that fails as well, as illustrated in the second 
> example.



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

Reply via email to