Description
I'm suffering from the collaped variable name scope of Groovy.
–
class VarsC {
p = 1
f1()
f2(p)
{ p = p }f3(p)
{ this.p = p }}
v = new VarsC()
assert v.p == 1
v.f1()
assert v.p == 'a'
v.f2('hello')
assert v.p == 'a'
v.f3("hello")
assert v.p == 'hello'
–
I cannot have a local var with the same name as the class field.
Arguments can clash with class fields too.
What I need is something to indicate that I'm declaring a new variable in the current scope, something like "var" or "any" or anything, even variable decorators used in Ruby.
This will help the ClassGenerator too in dealing cases such as nested closures.
Attachments
Issue Links
- is depended upon by
-
GROOVY-754 scoping
- Closed