The generalized conditions: a Dsymbol argument might need some runtime context. If so, they we should add them correctly.

In basic, `__traits` directive analyse its arguments as template parameters. Then `impl` is analysed to `VarExp` (`TypeIdentifier` -> (`TypeQualifierd::resolveHelper`) -> `VarExp`). But, "getMember" needs an expression as its `(*args)[0]`, so we should convert the `VarExp` to `DsymbolExp` to add implicit 'this'.

In other words, in here we should prefer `Dsymbol` than `Type` and `Expression`, and should wrap it in `DsymbolExp`. To do the first step, we already have a good function - `getDsymbol` (in template.c).

In conclusion, the code will be as follows:
```d
 src/traits.c | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/src/traits.c b/src/traits.c
index c57e2a5..7115819 100644
--- a/src/traits.c
+++ b/src/traits.c
@@ -305,17 +305,17 @@ Expression *TraitsExp::semantic(Scope *sc)
         }
         Identifier *id = Lexer::idPool((char *)se->string);
 
-        Type *t = isType(o);
-        e = isExpression(o);
-        Dsymbol *s = isDsymbol(o);
-        if (t)
-            e = typeDotIdExp(loc, t, id);
-        else if (e)
-            e = new DotIdExp(loc, e, id);
-        else if (s)
-        {   e = new DsymbolExp(loc, s);
+        /* Prefer dsymbol, because it might need some runtime contexts.
+         */
+        Dsymbol *sym = getDsymbol(o);
+        if (sym)
+        {   e = new DsymbolExp(loc, sym);
             e = new DotIdExp(loc, e, id);
         }
+        else if (Type *t = isType(o))
+            e = typeDotIdExp(loc, t, id);
+        else if (Expression *ex = isExpression(o))
+            e = new DotIdExp(loc, ex, id);
         else
         {   error("invalid first argument");
             goto Lfalse;
@@ -323,21 +323,16 @@ Expression *TraitsExp::semantic(Scope *sc)
 
         if (ident == Id::hasMember)
         {
-            if (t)
+            if (sym)
             {
-                Dsymbol *sym = t->toDsymbol(sc);
-                if (sym)
-                {
-                    Dsymbol *sm = sym->search(loc, id, 0);
-                    if (sm)
-                        goto Ltrue;
-                }
+                Dsymbol *sm = sym->search(loc, id, 0);
+                if (sm)
+                    goto Ltrue;
             }
 
             /* Take any errors as meaning it wasn't found
              */
             Scope *sc2 = sc->push();
-            //sc2->inHasMember++;
             e = e->trySemantic(sc2);
             sc2->pop();
             if (!e)
```