[Issue 5380] alias this is not considered with superclass lookup
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Nov 9 04:41:28 PST 2013
https://d.puremagic.com/issues/show_bug.cgi?id=5380
Denis Shelomovskij <verylonglogin.reg at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |verylonglogin.reg at gmail.com
Platform|Other |All
Summary|Subtyping with "alias this" |alias this is not
|doesn't mix with regular |considered with superclass
|inheritance |lookup
OS/Version|Linux |All
--- Comment #4 from Denis Shelomovskij <verylonglogin.reg at gmail.com> 2013-11-09 15:41:24 MSK ---
>From Kenji Hara's Issue 5973 description:
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'
---
---
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list