groovy/groovy-core — pull request #80 by andresteingress (2012-12-11 22:19:03+00:00)
Title: GROOVY-5632: Closure default params can cause BUG! exception in phase 'c...

Fixes [GROOVY-5632] (https://jira.codehaus.org/browse/GROOVY-5632) by introducing local variables for initial parameter values.

For a given function f() having two parameters carrying default expressions, the Verifier creates 2 synthetic methods whereas one of them has no parameters. Currently, the generated code for the no-arg method looks like this:

```groovy
def f() {
this.f((int) 3, (Object) { -> x })
}
```
This leads to the BUG! exception during compilation as the closure shared parameter x is not available in this special case.

This patch modifies verifier in this case and introduces a local variables to bypass the need for rewriting the original closure expression:

```groovy
def f() {
Reference x = new Reference((int) 3)
this.f((int) 3, (Object) { -> x })
}
```
Please investigate whether this approach is valid in terms of leaving the original VariableScope (referring to the method parameter) untouched, although referring to the local Reference variable instead of the parameter variable in the no-arg synthetic f() method.