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 2020/08/10 13:53:00 UTC
[jira] [Resolved] (GROOVY-7399) Method "with()" fails to call on
the object reference in Trait
[ https://issues.apache.org/jira/browse/GROOVY-7399?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles resolved GROOVY-7399.
---------------------------------
Fix Version/s: 3.0.6
4.0.0-alpha-1
Resolution: Fixed
> Method "with()" fails to call on the object reference in Trait
> --------------------------------------------------------------
>
> Key: GROOVY-7399
> URL: https://issues.apache.org/jira/browse/GROOVY-7399
> Project: Groovy
> Issue Type: Bug
> Components: groovy-runtime
> Reporter: Terry Wong
> Assignee: Eric Milles
> Priority: Major
> Fix For: 4.0.0-alpha-1, 3.0.6
>
>
> {code}
> class Bar implements FooTrait {
> def whoAmI() { "It's Bar" }
> }
> class Foo {
> def whoAmI() { "It's Foo" }
> }
> trait FooTrait {
> Foo f = new Foo()
> def hiFoo() {
> f.with {
> whoAmI() // it's Foo or Bar?!
> }
> }
> }
> Bar b = new Bar()
> assert b.hiFoo() == b.f.whoAmI()
> {code}
> I would expect the {{assert}} on last line will pass, but it failed with
> {noformat}
> Assertion failed:
> assert b.hiFoo() == b.f.whoAmI()
> | | | | | |
> | It's Bar| | | It's Foo
> | | | Foo@72967906
> | | Bar@5b8dfcc1
> | false
> Bar@5b8dfcc1
> {noformat}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)