Function dmd.dsymbol.Dsymbol.toParent2
parent
field returns a lexically enclosing scope symbol this is a member of.
toParent()
returns a logically enclosing scope symbol this is a member of.
It skips over TemplateMixin's and Nspaces that are mangleOnly.
toParent2()
returns an enclosing scope symbol this is living at runtime.
It skips over both TemplateInstance's and TemplateMixin's.
It's used when looking for the 'this' pointer of the enclosing function/class.
toParent3()
returns a logically enclosing scope symbol this is a member of.
It skips over TemplateMixin's.
Examples
module mod; template Foo(alias a) { mixin Bar!(); } mixin template Bar() { public { // ProtDeclaration void baz() { a = 2; } } } void test() { int v = 1; alias foo = Foo!(v); foo.baz(); assert(v == 2); }
// s == FuncDeclaration('mod.test.Foo!().Bar!().baz()') // s.parent == TemplateMixin('mod.test.Foo!().Bar!()') // s.toParent() == TemplateInstance('mod.test.Foo!()') // s.toParent2() == FuncDeclaration('mod.test')