Overriding a property ?

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Apr 14 14:13:59 PDT 2016


On 4/14/16 4:54 PM, Lucien wrote:
>
> You're right.
> In fact it didn't work because I did:
>
> ----------------------------
> class A
> {
>      @property foo() { return false; }
>      void myFunc() {  }
> }
>
> class B : A
> {
>      override @property foo() { return true; } // error
>      override void myFunc() {  }
> }
> ----------------------------
>
> When I remove the bool, the program compile but show the error when
> overriding.
> Is it a bug ?

Hm... I don't know. the error specifically says it's not supported. But 
it seems to me odd that it wouldn't. What is the harm in letting the 
derived function use inferred return type?

I don't know the reasoning behind the error condition, so I can say it's 
definitely not a bug, but I don't know why it's this way. Perhaps 
there's some situation that I'm not thinking of.

-Steve


More information about the Digitalmars-d-learn mailing list