www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5973] New: alias this is not considered with superclass lookup

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5973

           Summary: alias this is not considered with superclass lookup
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: k.hara.pg gmail.com



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: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 09 2011
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5973




Patch considering only alias this is here:
(It doesn't support opDot and opDispatch)
https://github.com/9rnsr/dmd/tree/MultiInheritPatch

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 09 2011