diff --git a/src/expression.c b/src/expression.c index 100e68243e13..03f2bc9e4b77 100644 --- a/src/expression.c +++ b/src/expression.c @@ -1186,17 +1186,11 @@ TemplateDeclaration *getFuncTemplateDecl(Dsymbol *s) if (f && f->parent) { TemplateInstance *ti = f->parent->isTemplateInstance(); - TemplateDeclaration *td; - if (ti && - !ti->isTemplateMixin() && - (ti->name == f->ident || - ti->toAlias()->ident == f->ident) - && - ti->tempdecl && - (td = ti->tempdecl->isTemplateDeclaration()) != NULL && - td->onemember) - { - return td; + if (ti && !ti->isTemplateMixin() && + ti->tempdecl && ((TemplateDeclaration *)ti->tempdecl)->onemember && + ti->tempdecl->ident == f->ident) + { + return (TemplateDeclaration *)ti->tempdecl; } } return NULL; diff --git a/test/runnable/template9.d b/test/runnable/template9.d index b7fe07c8cf4f..09ac649da94d 100644 --- a/test/runnable/template9.d +++ b/test/runnable/template9.d @@ -3411,6 +3411,28 @@ struct W12719(R) W12719!int a12719; +/******************************************/ +// 12746 + +template foo12746() +{ + void bar() + { + static assert(!__traits(compiles, bar(1))); + } + alias foo12746 = bar; +} + +void foo12746(int) +{ + assert(0); +} + +void test12746() +{ + foo12746(); // instantiate +} + /******************************************/ int main()