www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3537] New: Casting objects with alias this takes the subtype

http://d.puremagic.com/issues/show_bug.cgi?id=3537

           Summary: Casting objects with alias this takes the subtype
           Product: D
           Version: 2.036
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: tomeksowi gmail.com



PST ---
interface I { }

class A : I {
    int x;
    alias x this;
    void f() {
        auto i = cast(I) this;  // ouch
    }
}

Should work but doesn't:
Error: e2ir: cannot cast this.x of type int to type hello.I

The cast can be outside -- still the same error:

void main() {
    auto a = new A;
    auto i = cast(I) a;  // ouch
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 21 2009