Multiple alias this, what's the hold up?

Amex Amex at gmail.com
Sat Jun 15 10:12:46 UTC 2019


How many years has it been in limbo? 1? 2? 3? 5? 10?

What is the hold up?


Expression resolveAliasThis(Scope* sc, Expression e, bool gag = 
false)
{
     for (AggregateDeclaration ad = isAggregate(e.type); ad;)
     {
         if (ad.aliasthis)
         {
             uint olderrors = gag ? global.startGagging() : 0;
             Loc loc = e.loc;
             Type tthis = (e.op == TOK.type ? e.type : null);
             e = new DotIdExp(loc, e, ad.aliasthis.ident);
             e = e.expressionSemantic(sc);
             if (tthis && ad.aliasthis.needThis())
             {
                 if (e.op == TOK.variable)
                 {
                     if (auto fd = 
(cast(VarExp)e).var.isFuncDeclaration())
                     {
                         // 
https://issues.dlang.org/show_bug.cgi?id=13009
                         // Support better match for the 
overloaded alias this.
                         bool hasOverloads;
                         if (auto f = fd.overloadModMatch(loc, 
tthis, hasOverloads))
                         {
                             if (!hasOverloads)
                                 fd = f;     // use exact match
                             e = new VarExp(loc, fd, hasOverloads);
                             e.type = f.type;
                             e = new CallExp(loc, e);
                             goto L1;
                         }
                     }
                 }
                 /* non- at property function is not called inside 
typeof(),
                  * so resolve it ahead.
                  */
                 {
                     int save = sc.intypeof;
                     sc.intypeof = 1; // bypass "need this" error 
check
                     e = resolveProperties(sc, e);
                     sc.intypeof = save;
                 }
             L1:
                 e = new TypeExp(loc, new TypeTypeof(loc, e));
                 e = e.expressionSemantic(sc);
             }
             e = resolveProperties(sc, e);
             if (gag && global.endGagging(olderrors))
                 e = null;
         }

         import dmd.dclass : ClassDeclaration;
         auto cd = ad.isClassDeclaration();
         if ((!e || !ad.aliasthis) && cd && cd.baseClass && 
cd.baseClass != ClassDeclaration.object)
         {
             ad = cd.baseClass;
             continue;
         }
         break;
     }
     return e;
}



More information about the Digitalmars-d mailing list