Mercurial > projects > dstress
changeset 1036:8006b20664ca
Nested classes can't return delegates to their parents
<sky@quit-clan.de>
2006-05-24
news:bug-155-3@http.d.puremagic.com/bugzilla/
author | thomask |
---|---|
date | Thu, 01 Jun 2006 17:50:42 +0000 |
parents | 796acf477795 |
children | 22f348c04a9b |
files | run/d/delegate_17_A.d |
diffstat | 1 files changed, 51 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/d/delegate_17_A.d Thu Jun 01 17:50:42 2006 +0000 @@ -0,0 +1,51 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ <sky@quit-clan.de> +// @date@ 2006-05-24 +// @uri@ news:bug-155-3@http.d.puremagic.com/bugzilla/ + +module dstress.run.d.delegate_17_A; + +int status; + +class Foo{ + class Bar{ + int delegate() getDelegate(){ + return &sayHello; + } + } + Bar bar; + + int sayHello(){ + return ++status; + } + + this(){ + bar = new Bar(); + } +} + +int main(){ + Foo foo = new Foo(); + int delegate() hallo; + + hallo = foo.bar.getDelegate(); + + if(!hallo){ + assert(0); + } + if(status != 0){ + assert(0); + } + if(hallo() != 1){ + assert(0); + } + if(status != 1){ + assert(0); + } + + return 0; +} +