Marcin Erdmann created GROOVY-8201:
--------------------------------------

             Summary: 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)

Reply via email to