Is this a bug in overload resolution?

Timon Gehr timon.gehr at gmx.ch
Fri Mar 30 05:32:47 PDT 2012


On 03/30/2012 01:53 PM, Andrej Mitrovic wrote:
> 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?

Smells like a bug in the property function call syntax implementation.


More information about the Digitalmars-d-learn mailing list