paulk-asert commented on pull request #1674:
URL: https://github.com/apache/groovy/pull/1674#issuecomment-1009908404
I agree it would be good for the get and set behaviors to be aligned. The
suggested external behavior seems okay and I would add 'metaClass' as an
additional case to test for.
What worries me is the change in behavior for closures. The following
currently passes:
```
class Foo {
@Delegate Map m = [:]
def x = 4
protected y = 5
private z = 6
void method() {
def w = 3
assert 3 == { -> w }()
assert null == { -> x }()
assert null == { -> y }()
assert null == { -> z }()
}
}
class Bar {
def x = 4
protected y = 5
private z = 6
void method() {
def w = 3
assert 3 == { -> w }()
assert 4 == { -> x }()
assert 5 == { -> y }()
assert 6 == { -> z }()
}
}
new Foo().method()
new Bar().method()
```
This exhibits the "potentially strange" map takes precedence behavior but is
at least consistent across `x`, `y`, and `z`.
After the change, just the `x` behavior has altered precedence.
My suspicion is that what you have is close but needs some more work. I am
also thinking we might need to define a special Map metaclass that would
provide back the old behavior - again it would be good to align get/set even
for that case. Users relying on the old behavior could manually apply that
metaclass. I would regard this as a legacy compatibility mechanism rather than
something we would recommend is used for new development.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]