Bug 7799 – Can't use alias for overload resolution with alias this subtype

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-03-30T05:57:00Z
Last change time
2013-09-19T03:58:24Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2012-03-30T05:57:38Z
class Foo { bool test() { return true; } } class Bar { 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 quite weird as well.
Comment #1 by andrej.mitrovich — 2013-09-17T14:32:19Z
Works in 2.063.2.
Comment #2 by k.hara.pg — 2013-09-19T00:05:39Z
(In reply to comment #1) > Works in 2.063.2. Note that, even `alias super.test test` is compiled, but still cannot call it from FooBar object. // class definitions are same as comment#0 void main() { auto c = new FooBar(); assert(c.test()); // Error: this for test needs to be type Foo not type test.FooBar assert(c.test(1)); // OK } Currently D does not support expression alias, so `alias super.test test` would lost the implicit expression context 'foo' by alias this. Then, c.test() will be rewritten to `(c, Foo.test())`, and fails to compile.
Comment #3 by andrej.mitrovich — 2013-09-19T03:58:24Z
(In reply to comment #2) > (In reply to comment #1) > > Works in 2.063.2. > > Note that, even `alias super.test test` is compiled, but still cannot call it > from FooBar object. Hmm, so the test-case was incomplete. Should I reopen the issue or mark it as a duplicate of that other bug about expression alias not being supported? (I can't remember the bug number at the moment).