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

Changeset 587

Show
Ignore:
Timestamp:
07/25/10 02:09:37 (14 years ago)
Author:
walter
Message:

bugzilla 3706 delegates of interfaces with multiple inheritance fail

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dmd-1.x/src/expression.c

    r585 r587  
    60356035 
    60366036DelegateExp::DelegateExp(Loc loc, Expression *e, FuncDeclaration *f) 
    60376037        : UnaExp(loc, TOKdelegate, sizeof(DelegateExp), e) 
    60386038{ 
    60396039    this->func = f; 
    60406040} 
    60416041 
    60426042Expression *DelegateExp::semantic(Scope *sc) 
    60436043{ 
    60446044#if LOGSEMANTIC 
    60456045    printf("DelegateExp::semantic('%s')\n", toChars()); 
    60466046#endif 
    60476047    if (!type) 
    60486048    { 
    60496049        e1 = e1->semantic(sc); 
    60506050        type = new TypeDelegate(func->type); 
    60516051        type = type->semantic(loc, sc); 
    60526052        AggregateDeclaration *ad = func->toParent()->isAggregateDeclaration(); 
    60536053        if (func->needThis()) 
    60546054            e1 = getRightThis(loc, sc, ad, e1, func); 
     6055        if (ad && ad->type != e1->type) 
     6056        {   // A downcast is required for interfaces, see Bugzilla 3706 
     6057            e1 = new CastExp(loc, e1, ad->type); 
     6058            e1 = e1->semantic(sc); 
     6059        } 
    60556060    } 
    60566061    return this; 
    60576062} 
    60586063 
    60596064void DelegateExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 
    60606065{ 
    60616066    buf->writeByte('&'); 
    60626067    if (!func->isNested()) 
    60636068    { 
    60646069        expToCBuffer(buf, hgs, e1, PREC_primary); 
    60656070        buf->writeByte('.'); 
    60666071    } 
    60676072    buf->writestring(func->toChars()); 
    60686073} 
    60696074 
    60706075/************************************************************/ 
    60716076 
    60726077DotTypeExp::DotTypeExp(Loc loc, Expression *e, Dsymbol *s) 
    60736078        : UnaExp(loc, TOKdottype, sizeof(DotTypeExp), e) 
    60746079{ 
  • trunk/src/expression.c

    r585 r587  
    63706370DelegateExp::DelegateExp(Loc loc, Expression *e, FuncDeclaration *f, int hasOverloads) 
    63716371        : UnaExp(loc, TOKdelegate, sizeof(DelegateExp), e) 
    63726372{ 
    63736373    this->func = f; 
    63746374    this->hasOverloads = hasOverloads; 
    63756375} 
    63766376 
    63776377Expression *DelegateExp::semantic(Scope *sc) 
    63786378{ 
    63796379#if LOGSEMANTIC 
    63806380    printf("DelegateExp::semantic('%s')\n", toChars()); 
    63816381#endif 
    63826382    if (!type) 
    63836383    { 
    63846384        e1 = e1->semantic(sc); 
    63856385        type = new TypeDelegate(func->type); 
    63866386        type = type->semantic(loc, sc); 
    63876387        AggregateDeclaration *ad = func->toParent()->isAggregateDeclaration(); 
    63886388        if (func->needThis()) 
    63896389            e1 = getRightThis(loc, sc, ad, e1, func); 
     6390        if (ad && ad->type != e1->type) 
     6391        {   // A downcast is required for interfaces, see Bugzilla 3706 
     6392            e1 = new CastExp(loc, e1, ad->type); 
     6393            e1 = e1->semantic(sc); 
     6394        } 
    63906395    } 
    63916396    return this; 
    63926397} 
    63936398 
    63946399void DelegateExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 
    63956400{ 
    63966401    buf->writeByte('&'); 
    63976402    if (!func->isNested()) 
    63986403    { 
    63996404        expToCBuffer(buf, hgs, e1, PREC_primary); 
    64006405        buf->writeByte('.'); 
    64016406    } 
    64026407    buf->writestring(func->toChars()); 
    64036408} 
    64046409 
    64056410/************************************************************/ 
    64066411 
    64076412DotTypeExp::DotTypeExp(Loc loc, Expression *e, Dsymbol *s) 
    64086413        : UnaExp(loc, TOKdottype, sizeof(DotTypeExp), e) 
    64096414{