From 394a58a084386613e19636e84a4cfc024e224b2d Mon Sep 17 00:00:00 2001 From: k-hara Date: Sun, 29 Jun 2014 10:46:34 +0900 Subject: [PATCH] fix Issue 12981 - Can't refer to 'outer' from mixin template --- src/declaration.c | 3 ++- src/mtype.c | 2 ++ test/runnable/nested.d | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/declaration.c b/src/declaration.c index 642da52cb49d..b4c404c66604 100644 --- a/src/declaration.c +++ b/src/declaration.c @@ -2111,7 +2111,8 @@ bool VarDeclaration::isDataseg() return false; Dsymbol *parent = this->toParent(); if (!parent && !(storage_class & STCstatic)) - { error("forward referenced"); + { + error("forward referenced"); type = Type::terror; return false; } diff --git a/src/mtype.c b/src/mtype.c index 8820b716cd2c..0d7ec0bd8c98 100644 --- a/src/mtype.c +++ b/src/mtype.c @@ -8524,6 +8524,8 @@ Expression *TypeClass::dotExp(Scope *sc, Expression *e, Identifier *ident, int f } if (ident == Id::outer && sym->vthis) { + if (sym->vthis->scope) + sym->vthis->semantic(NULL); s = sym->vthis; } else diff --git a/test/runnable/nested.d b/test/runnable/nested.d index 3bba9357ef17..745f2944b335 100644 --- a/test/runnable/nested.d +++ b/test/runnable/nested.d @@ -2383,6 +2383,24 @@ void test12234() assert(b.a == 1); } +/*******************************************/ +// 12981 + +template Mix12981(T) +{ + class A + { + alias typeof(this.outer) x; + } +} + +class B12981 +{ + mixin Mix12981!(int); + + static assert(is(A.x == B12981)); +} + /*******************************************/ int main()