Skip to content

Commit

Permalink
Merge pull request #3884 from WalterBright/fix11946
Browse files Browse the repository at this point in the history
[reg] fix Issue 11946 - need 'this' to access member when passing field to template parameter
  • Loading branch information
AndrewEdwards authored and 9rnsr committed Aug 28, 2014
1 parent 4532cfe commit 8b7a3cb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/template.c
Expand Up @@ -1374,8 +1374,13 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch(
}
}

#if BUGZILLA_11946
if (isstatic)
tthis = NULL;
#else
if (toParent()->isModule() || (scope->stc & STCstatic))
tthis = NULL;
#endif
if (tthis)
{
bool hasttp = false;
Expand Down Expand Up @@ -6468,8 +6473,10 @@ void TemplateInstance::semantic(Scope *sc, Expressions *fargs)
sc2->parent = this;
sc2->tinst = this;
sc2->speculative = speculative;
#if BUGZILLA_11946
if (enclosing && tempdecl->isstatic)
sc2->stc &= ~STCstatic;
#endif

tryExpandMembers(sc2);

Expand Down
20 changes: 17 additions & 3 deletions test/runnable/template9.d
Expand Up @@ -2970,6 +2970,8 @@ void test11271()
/******************************************/
// 11533

version (none)
{
struct S11533
{
void put(alias fun)() { fun!int(); }
Expand Down Expand Up @@ -3002,6 +3004,20 @@ void test11533c()
assert(foo.call() == var);
}

void test11533()
{
test11533a();
test11533b();
test11533c();
}
}
else
{
void test11533()
{
}
}

/******************************************/
// 11553

Expand Down Expand Up @@ -4213,9 +4229,7 @@ int main()
test10811();
test10969();
test11271();
test11533a();
test11533b();
test11533c();
test11533();
test11818();
test11843();
test11872();
Expand Down

0 comments on commit 8b7a3cb

Please sign in to comment.