diff --git a/src/template.c b/src/template.c index 89df1efe8a18..046055b50f26 100644 --- a/src/template.c +++ b/src/template.c @@ -1568,39 +1568,20 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch( if (m == MATCHnomatch && prmtype->deco) m = farg->implicitConvTo(prmtype); - /* If no match, see if there's a conversion to a delegate - */ if (m == MATCHnomatch) { - Type *tbp = prmtype->toBasetype(); - Type *tba = farg->type->toBasetype(); - if (tbp->ty == Tdelegate) - { - TypeDelegate *td = (TypeDelegate *)prmtype->toBasetype(); - TypeFunction *tf = (TypeFunction *)td->next; - - if (!tf->varargs && Parameter::dim(tf->parameters) == 0) - { - m = deduceType(farg->type, paramscope, tf->next, parameters, dedtypes); - if (m == MATCHnomatch && tf->next->toBasetype()->ty == Tvoid) - m = MATCHconvert; - } - //printf("\tm2 = %d\n", m); - } - else if (AggregateDeclaration *ad = isAggregate(tba)) + AggregateDeclaration *ad = isAggregate(farg->type); + if (ad && ad->aliasthis) { - if (ad->aliasthis) + /* If a semantic error occurs while doing alias this, + * eg purity(bug 7295), just regard it as not a match. + */ + unsigned olderrors = global.startGagging(); + Expression *e = resolveAliasThis(sc, farg); + if (!global.endGagging(olderrors)) { - /* If a semantic error occurs while doing alias this, - * eg purity(bug 7295), just regard it as not a match. - */ - unsigned olderrors = global.startGagging(); - Expression *e = resolveAliasThis(sc, farg); - if (!global.endGagging(olderrors)) - { - farg = e; - goto Lretry; - } + farg = e; + goto Lretry; } } } @@ -1872,10 +1853,10 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch( } #if 0 - for (i = 0; i < dedargs->dim; i++) + for (size_t i = 0; i < dedargs->dim; i++) { - Type *t = (*dedargs)[i]; - printf("\tdedargs[%d] = %d, %s\n", i, t->dyncast(), t->toChars()); + RootObject *o = (*dedargs)[i]; + printf("\tdedargs[%d] = %d, %s\n", i, o->dyncast(), o->toChars()); } #endif @@ -3513,7 +3494,7 @@ MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *par fparam->type = fparam->type->addStorageClass(fparam->storageClass); fparam->storageClass &= ~(STC_TYPECTOR | STCin); } - //printf("\t-> this = %d, ", ty); print(); + //printf("\t-> this = %d, ", t->ty); t->print(); //printf("\t-> tparam = %d, ", tparam->ty); tparam->print(); /* See if tuple match diff --git a/test/runnable/template9.d b/test/runnable/template9.d index 0f32bea4dada..d9eab883ae68 100644 --- a/test/runnable/template9.d +++ b/test/runnable/template9.d @@ -4216,6 +4216,18 @@ void test13417() f13417(V13417!(4, float, "ijka")()); } +/******************************************/ +// 13484 + +int foo13484()(void delegate() hi) { return 1; } +int foo13484(T)(void delegate(T) hi) { return 2; } + +void test13484() +{ + assert(foo13484({}) == 1); // works + assert(foo13484((float v){}) == 2); // works <- throws error +} + /******************************************/ int main() @@ -4321,6 +4333,7 @@ int main() test13374(); test13378(); test13379(); + test13484(); printf("Success\n"); return 0;