On 03/26/2013 04:58 PM, Henning Pohl wrote:
> struct S {
> int value() {
> return 1;
> }
> }
>
> class Base {
> S s;
> alias s this;
> }
>
> class Derived : Base {
> void func() {
> int i = value();
> }
> }
>
> Fails with "main.d(14): Error: undefined identifier value".
> Explicitly casting this to Base works:
>
> void func() {
> int i = (cast(Base)this).value();
> }
>
> Is this intended or a bug?

Since alias this is for implicit conversions, it should be effective only when Base is used as an S. It is not obvious in the previous code that the programmer really wanted that.

I like the current behavior. I wonder what others think.

Also, this works as well:

        int i = super.value();

Ali

Reply via email to