https://issues.dlang.org/show_bug.cgi?id=12607

          Issue ID: 12607
           Summary: IUnknown classes cannot define or override a toString
                    method
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: [email protected]
          Reporter: [email protected]

Test 1:

-----
import core.sys.windows.windows;
import std.c.windows.com;

class C : IUnknown
{
    string toString() { return "E"; }

    extern(Windows) HRESULT QueryInterface(const(IID)*, void**) { return
typeof(return).init; }
    extern(Windows) uint AddRef() { return 0; }
    extern(Windows) uint Release() { return 0; }
}

void main() { }
-----

$ dmd test.d
> Deprecation: class test.C use of object.Object.toString() hidden by C is 
> deprecated. Use 'alias Object.toString toString;' to introduce base class 
> overload set.

Test 2:

-----
import core.sys.windows.windows;
import std.c.windows.com;

class C : IUnknown
{
    override string toString() { return "E"; }

    extern(Windows) HRESULT QueryInterface(const(IID)*, void**) { return
typeof(return).init; }
    extern(Windows) uint AddRef() { return 0; }
    extern(Windows) uint Release() { return 0; }
}

void main() { }
-----

$ dmd test.d
> Error: function test.C.toString does not override any function, did you mean 
> to override 'object.Object.toString'?

--

Reply via email to