Bug 16303 – covariant delegates should implicitly convert

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-07-20T08:51:00Z
Last change time
2017-06-10T20:44:45Z
Assigned to
nobody
Creator
bugzilla
See also
https://issues.dlang.org/show_bug.cgi?id=3075, https://issues.dlang.org/show_bug.cgi?id=17349

Comments

Comment #0 by bugzilla — 2016-07-20T08:51:44Z
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); }
Comment #1 by mathias.lang — 2016-07-20T09:15:25Z
I thought that was parameter contravariance and that could not work in the general case because of overloading ? AFAICS, it's a duplicate of https://issues.dlang.org/show_bug.cgi?id=3075
Comment #2 by bugzilla — 2017-04-26T18:44:23Z
Comment #3 by bugzilla — 2017-06-10T20:44:45Z