Bug 5973 – alias this is not considered with superclass lookup
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-05-09T21:18:21Z
Last change time
2018-11-04T00:02:02Z
Assigned to
No Owner
Creator
Kenji Hara
Comments
Comment #0 by k.hara.pg — 2011-05-09T21:18:21Z
Following should compile, but not.
(In comment, -> is superclass lookup, => is alias this lookup)
----
class A{ int a = 1; }
class B{ int b = 2; }
class C:A{
B obj;
alias obj this;
this(){ obj = new B(); }
}
class X:C{ }
void main()
{
auto c = new C();
assert(c.a == 1); // lookup C -> A, OK
assert(c.b == 2); // lookup C => B, OK
auto x = new X();
assert(x.a == 1); // lookup X -> C -> A, OK
assert(x.b == 2); // lookup X -> C => B, NG (Line 17)
}
----
test.d(17): Error: no property 'b' for type 'test.X'
----