Skip to content

Commit

Permalink
Fixes Issue 2452 - Better diagnostic on unimplemented interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrejMitrovic committed Jan 20, 2013
1 parent 2102028 commit 89543ab
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -1653,6 +1653,7 @@ int BaseClass::fillVtbl(ClassDeclaration *cd, FuncDeclarations *vtbl, int newins
assert(ifd);
// Find corresponding function in this class
tf = (ifd->type->ty == Tfunction) ? (TypeFunction *)(ifd->type) : NULL;
assert(tf); // should always be non-null
fd = cd->findFunc(ifd->ident, tf);
if (fd && !fd->isAbstract())
{
Expand All @@ -1676,8 +1677,10 @@ int BaseClass::fillVtbl(ClassDeclaration *cd, FuncDeclarations *vtbl, int newins
//printf(" not found\n");
// BUG: should mark this class as abstract?
if (!cd->isAbstract())
cd->error("interface function %s.%s isn't implemented",
id->toChars(), ifd->ident->toChars());
cd->error("interface function %s.%s%s isn't implemented",
id->toChars(), ifd->ident->toChars(),
Parameter::argsTypesToChars(tf->parameters, tf->varargs));

fd = NULL;
}
if (vtbl)
Expand Down
17 changes: 17 additions & 0 deletions test/fail_compilation/diag2452.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
TEST_OUTPUT:
---
fail_compilation/diag2452.d(14): Error: class diag2452.C interface function I.f(float p) isn't implemented
---
*/

interface I
{
void f(int p);
void f(float p);
}

class C : I
{
void f(int p) { }
}

0 comments on commit 89543ab

Please sign in to comment.