groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-7399) Method "with()" fails to call on the object reference in Trait
Date Thu, 01 Jun 2017 04:22:05 GMT

    [ https://issues.apache.org/jira/browse/GROOVY-7399?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16032413#comment-16032413
] 

Mark commented on GROOVY-7399:
------------------------------

Here's another variation --see line 8/9 which seems to ignore the {{.with}}

https://groovyconsole.appspot.com/script/5170505841639424

> 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
>
> {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
(v6.3.15#6346)

Mime
View raw message