[Issue 16303] New: covariant delegates should implicitly convert

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Jul 20 01:51:44 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=16303

          Issue ID: 16303
           Summary: covariant delegates should implicitly convert
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: bugzilla at digitalmars.com

Delegate arguments should be checked for covariance when implicitly converting
to a base delegate type:

--------------------------------------

void yayf(void function(int*) fp);
void yayd(void delegate(int*) dg);

void bar()
{
    void function(const(int)* p) fp;
    yayf(fp);                   // should be good but produces error

    void delegate(const(int)* p) dg;
    yayd(dg);                   // should be good but produces error
}


void nayf(void function(const(int)*) fp);
void nayd(void delegate(const(int)*) dg);

void bar()
{
    void function(int* p) fp;
    nayf(fp);                   // correctly produces error

    void delegate(int* p) dg;   // correctly produces error
    nayd(dg);
}

--


More information about the Digitalmars-d-bugs mailing list