Navigation Menu

Skip to content

Commit

Permalink
fix Issue 5554 - [qtd] Covariance detection failure
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Feb 21, 2012
1 parent f3ab2da commit 0c46d69
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/func.c
Expand Up @@ -461,13 +461,21 @@ void FuncDeclaration::semantic(Scope *sc)
return;

default:
{ FuncDeclaration *fdv = (FuncDeclaration *)b->base->vtbl.data[vi];
{ FuncDeclaration *fdv = (FuncDeclaration *)b->base->vtbl.tdata()[vi];
Type *ti = NULL;

/* Remember which functions this overrides
*/
foverrides.push(fdv);

#if DMDV2
/* Should we really require 'override' when implementing
* an interface function?
*/
//if (!isOverride())
//warning(loc, "overrides base class function %s, but is not marked with 'override'", fdv->toPrettyChars());
#endif

if (fdv->tintro)
ti = fdv->tintro;
else if (!type->equals(fdv->type))
Expand All @@ -492,10 +500,15 @@ void FuncDeclaration::semantic(Scope *sc)
}
if (ti)
{
if (tintro && !tintro->equals(ti))
if (tintro)
{
if (!tintro->nextOf()->equals(ti->nextOf()) &&
!tintro->nextOf()->isBaseOf(ti->nextOf(), NULL) &&
!ti->nextOf()->isBaseOf(tintro->nextOf(), NULL))
{
error("incompatible covariant types %s and %s", tintro->toChars(), ti->toChars());
}
}
tintro = ti;
}
goto L2;
Expand Down Expand Up @@ -569,7 +582,7 @@ void FuncDeclaration::semantic(Scope *sc)
if (f->varargs)
{
Lmainerr:
error("parameters must be main() or main(char[][] args)");
error("parameters must be main() or main(string[] args)");
}
}

Expand Down

0 comments on commit 0c46d69

Please sign in to comment.