Fix Issue 13478 - [REG2.066] Templates not emitted when also referenced in speculative contexts

On master, this has already been fixed as a by-product of
Kenji's minst/… rewrite of the instantiation tracking logic.
Merge pull request #3993 from klickverbot/2.066

Fix Issue 13478 - [REG2.066] Templates not emitted when also referenced in speculative contexts