4 /*******************************************************/
11 static class StaticInner
45 Outer p = new Outer();
51 Outer.StaticInner s = new Outer.StaticInner;
53 assert(s.foo() == 13);
55 Outer.Inner q = p.bar();
57 assert(q.foo(8) == 24*9+8);
60 /*******************************************************/
110 C1.C2.C3 r = q.foo();
111 assert(r.c3 == 2+24+8);
114 /*******************************************************/
152 /*******************************************************/
176 /*******************************************************/
202 /*******************************************************/
232 /*******************************************************/
267 /*******************************************************/
307 /*******************************************************/
354 /*******************************************************/
377 /*******************************************************/
405 /*******************************************************/
430 /*******************************************************/
460 /*******************************************************/
474 C14 c = new class C14
478 printf("in inner class\n");
486 /*******************************************************/
500 C15 c = new class(1,2) C15
504 printf("in inner class ctor\n");
511 printf("in inner class\n");
519 /*******************************************************/
547 /*******************************************************/
554 n = new Nested(this);
575 class OwnerDerived : Owner
581 OwnerDerived o = new OwnerDerived();
583 assert(o.n.foo() is o);
586 /*******************************************************/
616 Foo182 foo = new Foo182();
617 writefln("This should print Hello:");
619 foo.bar.doSayHello();
622 /*******************************************************/
653 Foo192 foo = new Foo192();
654 writefln("This should print Hello:");
656 foo.bar.doSayHello();
659 /*******************************************************/
676 Outer20 o = new Outer20;
678 Outer20.Inner oi = o.new Inner;
679 assert(oi.foo() == 3);
682 /*******************************************************/
686 static if (is(typeof(new class Foo21{}))) {}
692 /*******************************************************/
707 assert(this == i.foo());
713 Outer22 o = new Outer22;
717 /*******************************************************/
726 class AnonAdapter : Adapter23
732 Adapter23 a = cast( Adapter23 )( new AnonAdapter() );
738 Foo23 f = new Foo23();
740 Adapter23 a = cast( Adapter23 )( f.new AnonAdapter() );
741 auto aa = f.new AnonAdapter();
742 Adapter23 ab = cast( Adapter23 )(aa);
746 /*******************************************************/
750 public abstract void callI();
760 printf( "ok, this = %p\n", this);
765 auto i = new class() I24
767 override public void callI()
772 printf("bar.this = %p\n", this);
773 printf(" i.this = %p\n", (cast(void**)i)[2]);
774 assert(*cast(void**)&c24 == (cast(void**)i)[2]);
782 printf("c = %p\n", c24);
787 /*******************************************************/
794 alias typeof(Inner.tupleof) T;
798 /*******************************************************/
806 class B14046 : A14046
810 class NestedB : NestedA
814 this.outer.field = 1; // ok <- disallowed
816 //(cast(B14046)this.outer).field = 1; // workaround
823 auto b = new B14046();
824 auto nb = b.new NestedB();
825 assert(b.field == 0);
827 assert(b.field == 1);
830 /*******************************************************/
833 class AnimatedProgress15839(bool makeClosure)
835 static AnimatedProgress15839 saveThis;
837 interface Runnable {}
841 this(AnimatedProgress15839 ap)
843 assert(ap is saveThis);
849 assert(this is saveThis);
851 static if (makeClosure) int a;
853 auto r = new class Runnable
857 static assert(is(typeof(this.outer) == AnimatedProgress15839));
858 assert(this.outer is saveThis);
860 GC gc = new GC(this.outer);
862 static if (makeClosure) int b = a;
871 auto ap1 = new AnimatedProgress15839!false();
875 auto ap2 = new AnimatedProgress15839!true();
880 /*******************************************************/