http://d.puremagic.com/issues/show_bug.cgi?id=3706


Don <clugd...@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
            Version|1.054                       |D1 & D2
         OS/Version|Mac OS X                    |All


--- Comment #3 from Don <clugd...@yahoo.com.au> 2010-07-22 13:55:22 PDT ---
The problem lies in delegate expressions formed from interfaces. We need to
ensure that the correct interface is used, otherwise the vtblIndex will refer
to the wrong one.
Applies to both D1 and D2.

PATCH: expression.c, not yet fully tested in the test suite. Maybe this patch
should be made in getRightThis() instead?

Expression *DelegateExp::semantic(Scope *sc)
{
#if LOGSEMANTIC
    printf("DelegateExp::semantic('%s')\n", toChars());
#endif
    if (!type)
    {
        e1 = e1->semantic(sc);
        type = new TypeDelegate(func->type);
        type = type->semantic(loc, sc);
        AggregateDeclaration *ad = func->toParent()->isAggregateDeclaration();
        if (func->needThis())
            e1 = getRightThis(loc, sc, ad, e1, func);
+        if (ad && ad->type != e1->type)
+        {   // A downcast is required for interfaces
+            e1 = new CastExp(loc, e1, ad->type);
+            e1 = e1->semantic(sc);
+        }
    }
    return this;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to