class Foo
{
    bool test() { return true; }
}

class Bar
{
    this() { foo = new Foo; }
    Foo foo;
    alias foo this;
}

class FooBar : Bar
{
    bool test(int x) { return true; }
    alias super.test test;
}

void main() {}

test.d(17): Error: 'this' is only defined in non-static member
functions, not FooBar
test.d(17): Error: alias test.FooBar.test cannot alias an expression
(__error).foo.test

The error message is odd. I'm trying to bring in the overloads of the
'test' function from the base class. But it doesn't seem to work if
the overloads are in an 'alias this' field and not the base class
itself.

If I comment out the "alias super.test test;" line I can access the
function from the 'foo' subtype:
void main()
{
    auto foobar = new FooBar;
    foobar.Bar.test();  // calls 'foo.test'
}

So I'm thinking "alias super.test test;" should work. Bug?

Reply via email to