[Issue 13867] New: Overriding a method from an extern(C++) interface requires extern(C++) on the method definition
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Mon Dec 15 13:43:38 PST 2014
    
    
  
https://issues.dlang.org/show_bug.cgi?id=13867
          Issue ID: 13867
           Summary: Overriding a method from an extern(C++) interface
                    requires extern(C++) on the method definition
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: redballoon36 at gmail.com
Code example:
extern(C++) interface INTERFACE
{
    void aMethod();
}
class CLASS : INTERFACE
{
    override void aMethod() { }
}
With this code, dmd 2.066 gives the error:
Function CLASS.aMethod does not override any function, did you mean to override
'INTERFACE.aMethod'?
Changing the definition to:
extern(C++) override void aMethod() { }
satisfies the requirements for overload.
Immediate problem: The error message does not provide sufficient information to
identify the issue.
However, I think it would be better for the method in CLASS to override the
method in INTERFACE without the extern(C++) attribute.  There is no way for the
call-site to distinguish between a method that is extern(C++) vs. simply
extern(D).  Though I don't know how to make it work if CLASS also implements a
normal D interface that also has aMethod, e.g.
interface DINTERFACE
{
    void aMethod();
}
class CLASS : INTERFACE, DINTERFACE
{
    override void aMethod() { }
}
So the only fix I see right now is to improve the diagnostic message.
--
    
    
More information about the Digitalmars-d-bugs
mailing list