2013/4/10 Dicebot <m.strashun@gmail.com>
On Wednesday, 10 April 2013 at 09:37:44 UTC, kenji hara wrote:
OK. I don't understand the issue enough, but I'd like to help you.

- TemplateInstance::tinst may represent the enclosing template instance
that 'this' instance is instantiated. It is set in
TemplateInstance::semantic(|2|3) for its member's semantic process.

- TemplateInstance::enclosing may represent the parent of nested template
instance. If a template is instantiated in function scope with implicit
context, it points the function. It is set in
TemplateInstance::hasNestedArgs.

- Module::importedFrom may represents the "root module" of import chain. it
points one of the module that listed in command line.

Good luck.

Kenji Hara

I see no TemplateInstance::enclosing, only Scope::enclosing and TemplateInstance is not Scope descendant.

Very recently TemplateInstance::isnested is renamed to TemplateInstance::enclosing.
 
Essentially I need to emit symbols not for "importedFrom" module but for module of top-most tinst in chain. I supposed that iterating tinst can do the trick, but it is not. For example, when map is used, it call templated range functions somewhere down the line and iterating up from those don't get you initial map call scope. (Same issue in printInstantiationTrace as it uses this method).

It sounds that using TemplateInstance::enclosing is correct.

Kenji Hara