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' ----
Comment #1 by k.hara.pg — 2011-05-09T21:35:29Z
Patch considering only alias this is here: (It doesn't support opDot and opDispatch) https://github.com/9rnsr/dmd/tree/MultiInheritPatch
Comment #2 by verylonglogin.reg — 2013-11-09T04:38:39Z
*** This issue has been marked as a duplicate of issue 5380 ***
Comment #3 by razvan.nitu1305 — 2018-10-09T17:09:14Z
Reopening as 5380 and 5973 are slightly different. 5380 is a bug of implicit conversion while this one is a bug of symbol resolution
Comment #4 by razvan.nitu1305 — 2018-10-11T14:51:29Z
Comment #5 by github-bugzilla — 2018-11-04T00:02:01Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/4a9ad749593caa7979216563f8be71809ca97e80 Fix Issue 5973 - alias this is not considered with superclass lookup https://github.com/dlang/dmd/commit/e537dfdd8a04282b58b1d85905e81cac78fc12a3 Merge pull request #8822 from RazvanN7/Issue_5973 Fix Issue 5973 - alias this is not considered with superclass lookup merged-on-behalf-of: Nicholas Wilson <[email protected]>