Thread overview
[Issue 9779] New: Improperly implemented interface methods should emit a better diagnostic
Mar 21, 2013
Andrej Mitrovic
Mar 21, 2013
Andrej Mitrovic
March 21, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9779

           Summary: Improperly implemented interface methods should emit a
                    better diagnostic
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: andrej.mitrovich@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-03-21 10:25:03 PDT ---
interface I
{
    void foo(int count, int** ptr);
}

class C : I
{
    void foo(int count, float** ptr) { }
}

void main()
{
}

$ dmd test.d
> (6): Error: class test.C interface function 'void foo(int count, int** ptr)' is not implemented

If there is a name match between an implementation method and an interface method, the diagnostic should list the implemented method as a partial match, and should probably show why it doesn't implement the interface method:

> (6): Error: class test.C interface function 'void foo(int count, int** ptr)' is not implemented
> (8): Partial match: 'void foo(int count, float** ptr)'
> (8):     : Parameter #2: 'float**' does not match interface parameter 'int**'

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 21, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9779


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #1 from bearophile_hugs@eml.cc 2013-03-21 11:48:07 PDT ---
This seems a nice idea.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 21, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9779



--- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-03-21 11:50:20 PDT ---
(In reply to comment #1)
> This seems a nice idea.

The same idea can be extended for overrides:

class B
{
    void foo(int count, int** ptr) { }
}

class C : B
{
    override void foo(int count, float** ptr) { }
}

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