You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2023/07/31 18:33:00 UTC
[jira] [Created] (GROOVY-11142) this reference in trait fails to resolve properly
Eric Milles created GROOVY-11142:
------------------------------------
Summary: 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
Reporter: Eric Milles
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)