I ran into an issue with cross referencing to classes, that I can't figure out. I reproduced the issue below:

import std.stdio;

class Base(t)
{
        public void Foo(A!(t) a)
        {
                writeln("Base.Foo(A a)");
        }

        public void Foo(B!(t) a)
        {
                writeln("Base.Foo(B a)");
        }
};

class A(t) : Base!(t)
{
        public t v;
        this(t v)
        {
                this.v = v;
        }
}

class B(t) : Base!(t)
{
        public override void Foo(A!(t) a)
        {
                writeln("A: ", a.v);
        }
}

int main()
{
        A!int a = new A!(int)(1);
        B!int b = new B!(int)();

        a.Foo(b);
        b.Foo(a);

        return 0;
}

And the errors dmd returns:
test.d(16): Error: class test.A!int.A is forward referenced when looking for 'v' test.d(16): Error: class test.A!int.A is forward referenced when looking for 'opDot' test.d(16): Error: class test.A!int.A is forward referenced when looking for 'opDispatch'
test.d(29): Error: no property 'v' for type 'test.A!int.A'
test.d(10): Error: template instance test.B!int error instantiating
test.d(16):        instantiated from here: Base!int
test.d(35):        instantiated from here: A!int

Is this a bug in D?  Or am I doing something wrong?

Reply via email to