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

Daniel Sun resolved GROOVY-8201.
--------------------------------
    Resolution: Fixed

> 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
>            Assignee: Daniel Sun
>            Priority: Minor
>             Fix For: 7.0.0-alpha-1
>
>
> 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
(v10.3.26#10030026)

Reply via email to