Is this actually valid code?

Andrej Mitrovic andrej.mitrovich at gmail.com
Sun Nov 6 20:10:57 PST 2011


I've had a simple problem where I've only wanted to override a setter
from a base class:

class Foo
{
    @property void test(int) {}
    @property int test() { return 1; }
}

class Bar : Foo
{
    override @property void test(int) {}
    void bartest() { auto x = test; }  // NG
}

test.d(19): Error: function test.Bar.test (int _param_0) is not
callable using argument types ()

So I thought I'd be clever:

class Foo
{
    @property void test(int) {}
    @property int test() { return 1; }
}

class Bar : Foo
{
    alias super.test test;
    override @property void test(int) {}
    void bartest() { auto x = test; }
}

And it actually works! Is this a documented feature?


More information about the Digitalmars-d-learn mailing list