Skip to content

Commit

Permalink
Issue 5046 - Wrong type of implicit 'this' in struct/class templates
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr authored and WalterBright committed Jul 19, 2011
1 parent 391c999 commit ca51706
Showing 1 changed file with 19 additions and 23 deletions.
42 changes: 19 additions & 23 deletions src/template.c
Expand Up @@ -169,6 +169,25 @@ int match(Object *o1, Object *o2, TemplateDeclaration *tempdecl, Scope *sc)
* we'll do that another day.
*/

if (s1)
{
VarDeclaration *v1 = s1->isVarDeclaration();
if (v1 && v1->storage_class & STCmanifest)
{ ExpInitializer *ei1 = v1->init->isExpInitializer();
if (ei1)
e1 = ei1->exp, s1 = NULL;
}
}
if (s2)
{
VarDeclaration *v2 = s2->isVarDeclaration();
if (v2 && v2->storage_class & STCmanifest)
{ ExpInitializer *ei2 = v2->init->isExpInitializer();
if (ei2)
e2 = ei2->exp, s2 = NULL;
}
}

if (t1)
{
/* if t1 is an instance of ti, then give error
Expand Down Expand Up @@ -215,30 +234,7 @@ int match(Object *o1, Object *o2, TemplateDeclaration *tempdecl, Scope *sc)
else if (s1)
{
if (!s2 || !s1->equals(s2) || s1->parent != s2->parent)
{
if (s2)
{
VarDeclaration *v1 = s1->isVarDeclaration();
VarDeclaration *v2 = s2->isVarDeclaration();
if (v1 && v2 && v1->storage_class & v2->storage_class & STCmanifest)
{ ExpInitializer *ei1 = v1->init->isExpInitializer();
ExpInitializer *ei2 = v2->init->isExpInitializer();
if (ei1 && ei2 && ei1->exp->equals(ei2->exp))
goto Lmatch;
}
}
goto Lnomatch;
}
#if DMDV2
VarDeclaration *v1 = s1->isVarDeclaration();
VarDeclaration *v2 = s2->isVarDeclaration();
if (v1 && v2 && v1->storage_class & v2->storage_class & STCmanifest)
{ ExpInitializer *ei1 = v1->init->isExpInitializer();
ExpInitializer *ei2 = v2->init->isExpInitializer();
if (ei1 && ei2 && !ei1->exp->equals(ei2->exp))
goto Lnomatch;
}
#endif
}
else if (v1)
{
Expand Down

0 comments on commit ca51706

Please sign in to comment.