diff --git a/src/expression.c b/src/expression.c index a69210c6b79d..f17e5004ba91 100644 --- a/src/expression.c +++ b/src/expression.c @@ -2817,7 +2817,11 @@ Expression *DsymbolExp::semantic(Scope *sc) TemplateDeclaration *td = s->isTemplateDeclaration(); if (td) { - e = new TemplateExp(loc, td); + Dsymbol *p = td->toParent2(); + if (hasThis(sc) && p && p->isAggregateDeclaration()) + e = new DotTemplateExp(loc, new ThisExp(loc), td); + else + e = new TemplateExp(loc, td); e = e->semantic(sc); return e; } diff --git a/test/runnable/template9.d b/test/runnable/template9.d index 5a26eeb8578c..0806cad2ae78 100644 --- a/test/runnable/template9.d +++ b/test/runnable/template9.d @@ -519,6 +519,25 @@ struct T6805 } static assert(is(T6805.xxx.Type == int)); +/**********************************/ +// 6738 + +struct Foo6738 +{ + int _val = 10; + + @property int val()() { return _val; } + int get() { return val; } // fail +} + +void test6738() +{ + Foo6738 foo; + auto x = foo.val; // ok + assert(x == 10); + assert(foo.get() == 10); +} + /**********************************/ // 6994 @@ -775,6 +794,7 @@ int main() test2778get(); test6208a(); test6208b(); + test6738(); test6994(); test3467(); test4413();