Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 787

Show
Ignore:
Timestamp:
12/06/10 08:48:16 (14 years ago)
Author:
walter
Message:

bugzilla 5020 Forward implicit bool conversions to alias this

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/expression.c

    r779 r787  
    12501250{ 
    12511251    // Default is 'yes' - do nothing 
    12521252 
    12531253#ifdef DEBUG 
    12541254    if (!type) 
    12551255        dump(0); 
    12561256#endif 
    12571257 
    12581258    // Structs can be converted to bool using opCast(bool)() 
    12591259    Type *tb = type->toBasetype(); 
    12601260    if (tb->ty == Tstruct) 
    12611261    {   AggregateDeclaration *ad = ((TypeStruct *)tb)->sym; 
    12621262        /* Don't really need to check for opCast first, but by doing so we 
    12631263         * get better error messages if it isn't there. 
    12641264         */ 
    12651265        Dsymbol *fd = search_function(ad, Id::cast); 
    12661266        if (fd) 
    12671267        { 
    12681268            Expression *e = new CastExp(loc, this, Type::tbool); 
    12691269            e = e->semantic(sc); 
     1270            return e; 
     1271        } 
     1272 
     1273        // Forward to aliasthis. 
     1274        if (ad->aliasthis) 
     1275        { 
     1276            Expression *e = new DotIdExp(loc, this, ad->aliasthis->ident); 
     1277            e = e->semantic(sc); 
     1278            e = e->checkToBoolean(sc); 
    12701279            return e; 
    12711280        } 
    12721281    } 
    12731282 
    12741283    if (!type->checkBoolean()) 
    12751284    {   if (type->toBasetype() != Type::terror) 
    12761285            error("expression %s of type %s does not have a boolean value", toChars(), type->toChars()); 
    12771286        return new ErrorExp(); 
    12781287    } 
    12791288    return this; 
    12801289} 
    12811290 
    12821291/**************************** 
    12831292 */ 
    12841293 
    12851294Expression *Expression::checkToPointer() 
    12861295{ 
    12871296    //printf("Expression::checkToPointer()\n"); 
    12881297    Expression *e = this; 
    12891298