Permalink
Browse files

Fixes Issue 7408 - __traits(compiles) should work on builtin template…

… instance properties.
  • Loading branch information...
1 parent bc8b981 commit 968cb4faf0ffd9b5b379a8c27f4f4da42e6bc1a5 @AndrejMitrovic AndrejMitrovic committed Jan 10, 2013
Showing with 17 additions and 1 deletion.
  1. +4 −1 src/mtype.c
  2. +13 −0 test/runnable/traits.d
View
@@ -6489,6 +6489,7 @@ void TypeQualified::resolveHelper(Loc loc, Scope *sc,
VarDeclaration *v;
EnumMember *em;
Expression *e;
+ TemplateInstance *ti;
#if 0
printf("TypeQualified::resolveHelper(sc = %p, idents = '%s')\n", sc, toChars());
@@ -6514,6 +6515,7 @@ void TypeQualified::resolveHelper(Loc loc, Scope *sc,
{ Type *t;
v = s->isVarDeclaration();
+ ti = s->isTemplateInstance();
if (v && id == Id::length)
{
e = new VarExp(loc, v);
@@ -6522,7 +6524,8 @@ void TypeQualified::resolveHelper(Loc loc, Scope *sc,
goto Lerror;
goto L3;
}
- else if (v && (id == Id::stringof || id == Id::offsetof))
+ else if ((v && (id == Id::stringof || id == Id::offsetof))
+ || (ti && (id == Id::stringof || id == Id::mangleof)))
{
e = new DsymbolExp(loc, s, 0);
do
View
@@ -967,6 +967,18 @@ void test5978() {
/*************************************************************/
+template T7408() { }
+
+void test7408()
+{
+ auto x = T7408!().stringof;
+ auto y = T7408!().mangleof;
+ static assert(__traits(compiles, T7408!().stringof));
+ static assert(__traits(compiles, T7408!().mangleof));
+ static assert(!__traits(compiles, T7408!().init));
+ static assert(!__traits(compiles, T7408!().offsetof));
+}
+
int main()
{
test1();
@@ -996,6 +1008,7 @@ int main()
test7608();
test7858();
test5978();
+ test7408();
writeln("Success");
return 0;

0 comments on commit 968cb4f

Please sign in to comment.