Details
-
Sub-task
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.0.6
-
None
-
None
Description
The following code exhibits the problem:
class Owner { Object delegate String ownerProp = "owner" void run() { def c = { delegateProp = ownerProp } c.delegate = delegate c.resolveStrategy = Closure.DELEGATE_FIRST c() assert c.delegate.delegateProp == ownerProp } } class Delegate { String delegateProp = "delegate" } class Container { static class Delegate { String delegateProp = "delegate" } } // works fine new Owner(delegate: new Delegate()).run() // not work so fine: // groovy.lang.MissingFieldException: No such field: ownerProp for class: Containergroovy.lang.MissingFieldException: No such field: ownerProp for class: Container new Owner(delegate: new Container.Delegate()).run()
The problem appears to be that when what is effectively âpropertyMissingâ (i.e. the generated impl) is called for a class that is an inner class, a MissingFieldException is thrown. Inside the implementation of Closure#getPropertyTryThese(â¦), there is no handling for MissingFieldException (only MissingPropertyException). My naive opinion is that it's wrong for a MissingFieldException to be thrown in the first place.
Attachments
Issue Links
- relates to
-
GROOVY-6299 invokeMethod() not called for static inner classes.
- Open