I'm not sure if this is a bug, or an anti-pattern, or what, but I ran
into this issue yesterday:

        class Base {
                int propImpl;
                final @property int prop() { return propImpl; }
                @property void prop(int newVal) { propImpl = newVal; }

                void someMethod() {
                        auto x = prop; // OK, calls Base.prop()
                        prop = x; // OK, calls Base.prop(int)
                }
        }

        class Derived : Base {
                override @property void prop(int newVal) {
                        super.prop(newVal);
                        doSomethingElse(newVal);
                }

                void someOtherMethod() {
                        auto x = prop; // NG - compile error ***
                        auto y = super.prop; // OK, calls Base.prop()
                        prop = x; // OK, calls Derived.prop()
                }
        }

Basically, once the derived class overrides the property setter, the
(un-overridden) base class getter somehow becomes shadowed as well, and
references to .prop will cause a compile error saying that Derived.prop
can't be called without parameters.

So, what's going on here? Should this code be accepted? Is this a
compiler / language bug? A deliberate @property limitation? Or just more
evidence @property should be taken out the back and shot?


T

-- 
This sentence is false.

Reply via email to