Skip to content

Commit

Permalink
dmd.dtemplate: Recurse through the primary instantiation, skip if 'in…
Browse files Browse the repository at this point in the history
…st' was set to null
  • Loading branch information
ibuclaw committed Jan 10, 2023
1 parent 39bd972 commit 6739d65
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions compiler/src/dmd/dtemplate.d
Original file line number Diff line number Diff line change
Expand Up @@ -6263,7 +6263,7 @@ extern (C++) class TemplateInstance : ScopeDsymbol

// When no errors instantiating, this should only be called on
// the primary instantiation.
assert(this is inst || inst is null);
assert(this is inst);

if (global.params.allInst)
{
Expand All @@ -6275,11 +6275,9 @@ extern (C++) class TemplateInstance : ScopeDsymbol
return ThreeState.yes;

// Do codegen if the ancestor needs it.
if (tinst && tinst.inst && tinst !is tinst.inst)
tinst = tinst.inst;
if (tinst && tinst.needsCodegen())
if (tinst && tinst.inst && tinst.inst.needsCodegen())
{
tithis.minst = tinst.minst; // cache result
tithis.minst = tinst.inst.minst; // cache result
assert(tithis.minst);
assert(tithis.minst.isRoot());
return ThreeState.yes;
Expand Down Expand Up @@ -6337,10 +6335,9 @@ extern (C++) class TemplateInstance : ScopeDsymbol
// If the ancestor isn't speculative,
// 1. do codegen if the ancestor needs it
// 2. elide codegen if the ancestor doesn't need it (non-root instantiation of ancestor incl. subtree)
if (tinst)
if (tinst && tinst.inst) // and not a dummy instance (see evaluateConstraint)
{
if (tinst.inst && tinst !is tinst.inst)
tinst = tinst.inst;
tinst = tinst.inst;
const needsCodegen = tinst.needsCodegen(); // sets tinst.minst
if (tinst.minst) // not speculative
{
Expand Down

0 comments on commit 6739d65

Please sign in to comment.