www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Generic Inner Class Inheritance

reply "Garett Bass" <garettbass studiotekne.com> writes:
Under DMD 0.136 and 0.137, generic inner classes cannot
inherit from abstract inner classes.  Is this the intended
behavior?

class Outer {
    int x;

    abstract class AbstractInner {
        void f();
    }

    class GenericInner(T) : AbstractInner {
        T t;
        void f() { writefln("GenericInner.f()"); x = 2; }
    }
    class ConcreteInner : AbstractInner {
        void f() { writefln("ConcreteInner.f()"); x = 2; }
    }

    this() {
        auto AbstractInner g = new GenericInner!(int)(); // Error
        auto AbstractInner c = new ConcreteInner();      // Ok
    }
}

Error message: "class main.Outer.GenericInner!(int).GenericInner
super class Abstract Inner is nested within Outer, not
GenericInner!(int)

Regards,
Garett 
Nov 02 2005
next sibling parent "Walter Bright" <newshound digitalmars.com> writes:
Looks like a compiler bug.
Nov 05 2005
prev sibling parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Garett Bass schrieb am 2005-11-02:
 Under DMD 0.136 and 0.137, generic inner classes cannot
 inherit from abstract inner classes.  Is this the intended
 behavior?

 class Outer {
     int x;

     abstract class AbstractInner {
         void f();
     }

     class GenericInner(T) : AbstractInner {
         T t;
         void f() { writefln("GenericInner.f()"); x = 2; }
     }
     class ConcreteInner : AbstractInner {
         void f() { writefln("ConcreteInner.f()"); x = 2; }
     }

     this() {
         auto AbstractInner g = new GenericInner!(int)(); // Error
         auto AbstractInner c = new ConcreteInner();      // Ok
     }
 }

 Error message: "class main.Outer.GenericInner!(int).GenericInner
 super class Abstract Inner is nested within Outer, not
 GenericInner!(int)
Added to DStress as http://dstress.kuehne.cn/run/t/template_class_12_A.d http://dstress.kuehne.cn/run/t/template_class_12_B.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFDbtPL3w+/yD4P9tIRApD1AKCvro6C2VQ/16RWxjCl5NHWfxmBfwCfav5E eAKrFR9R9nMM/8TF3T+/p5Y= =QaY2 -----END PGP SIGNATURE-----
Nov 06 2005