[Issue 12613] New: Diagnostic for calling convention mismatch when implementing/overriding methods should improve

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Apr 22 07:37:25 PDT 2014


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

          Issue ID: 12613
           Summary: Diagnostic for calling convention mismatch when
                    implementing/overriding methods should improve
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: diagnostic
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: andrej.mitrovich at gmail.com
          Reporter: andrej.mitrovich at gmail.com

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

interface IFoo
{
    void foo();
}

abstract class Foo : IFoo
{
    void foo_impl() { }
}

class C : Foo, IUnknown
{
    void foo() { }

    override void foo_impl() { }

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

void main()
{
}
-----

Note that COM classes by default have the extern(System) calling convention,
hence why the above neither implements 'foo' nor overrides 'foo_impl'. The
diagnostics are:

-----
test.d(14): Error: class test.C interface function 'void foo()' is not
implemented
test.d(18): Error: function test.C.foo_impl does not override any function, did
you mean to override 'test.Foo.foo_impl'?
-----

The compiler should emit the calling convention of the two methods if they
don't match.

--


More information about the Digitalmars-d-bugs mailing list