Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
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