Issue Details (XML | Word | Printable)

Key: GROOVY-2198
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Jochen Theodorou
Reporter: Jochen Theodorou
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
groovy

owner/delegatechain is broken for multiple delegates

Created: 12/Oct/07 12:41 PM   Updated: 12/Oct/07 12:42 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.1-rc-1

Time Tracking:
Not Specified


 Description  « Hide
the following script should not fail:
class A {
    def del;
    String toString(){del}
    def whoisThis() { return this }
    def met() { return "I'm the method inside '"+del+"'" }
 }

 def outerdel= new A(del: "outer delegate" )
 def innerdel= new A(del: "inner delegate")

 def cout= {
   assert delegate == outerdel
   assert delegate.whoisThis() == outerdel
   assert delegate.del == "outer delegate"
   assert delegate.met() == "I'm the method inside 'outer delegate'"

   assert whoisThis() == outerdel
   assert del == "outer delegate"
   assert met() == "I'm the method inside 'outer delegate'"

   def cin= {
       assert delegate == innerdel
       assert delegate.whoisThis() == innerdel
       assert delegate.del == "inner delegate"
       assert delegate.met() == "I'm the method inside 'inner delegate'"

       assert whoisThis() == outerdel
       assert del == "outer delegate"
       assert met() == "I'm the method inside 'outer delegate'"
   }

   cin.delegate= innerdel
   cin()
 }

 cout.delegate= outerdel
 cout()

it fails in the last three asserts for whoisThis() and met(), because the inner delegate is choosen instead of the outer



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Jochen Theodorou added a comment - 12/Oct/07 12:42 PM
fixed