You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "John Wagenleitner (JIRA)" <ji...@apache.org> on 2017/05/24 01:51:04 UTC

[jira] [Commented] (GROOVY-8201) methodMissing() is incorrectly called when calling a method on closure owner using this keyword

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

John Wagenleitner commented on GROOVY-8201:
-------------------------------------------

This appears to be caused by the [fix 34ad466b|https://github.com/apache/groovy/commit/34ad466ba6a87a5eb26cf4a444f817299b744edb] for GROOVY-6263.

> methodMissing() is incorrectly called when calling a method on closure owner using this keyword
> -----------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-8201
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8201
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.5.0-alpha-1
>            Reporter: Marcin Erdmann
>            Priority: Minor
>
> This is a really edge-case'y regression in 2.5.0-alpha-1 discovered while checking if Geb's codebase will compile and the tests succeed using that version.
> Given the following class:
> {code}
> class RegressionReproducingClass {
>     Closure getClosure() {
>         { -> this.getValue() }
>     }
>     String getValue() {
>         'foo'
>     }
>     def methodMissing(String name, args) {
>         throw new Exception("Should never get here!")
>     }
> }
> {code}
> The following test:
> {code}
> class RegressionReproducingSpec extends Specification {
>     def test() {
>         given:
>             def closure = new RegressionReproducingClass().closure
>         expect:
>             closure() == 'foo'
>     }
> }
> {code}
> Fails with:
> {noformat}
> Condition failed with Exception:
> closure() == 'foo'
> |
> java.lang.Exception: Should never get here!
> {noformat}
> Any of the following actions makes this sample pass:
> * reverting the version to 2.4.11
> * removing {{methodMissing()}}
> * changing the code in closure to use property access, i.e. {{this.value}}
> * changing the code in closure not to use this, i.e. {{getValue()}}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)