Bug 10219 – Implicit conversion between delegates returning a class and an interface

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-05-31T10:55:00Z
Last change time
2014-05-31T21:15:24Z
Keywords
accepts-invalid, pull, wrong-code
Assigned to
nobody
Creator
verylonglogin.reg

Comments

Comment #0 by verylonglogin.reg — 2013-05-31T10:55:56Z
--- interface I { } class C: I { } void f(I delegate(C) del) { C c = new C; void* cPtr = cast(void*) c; void* iPtr = cast(void*) cast(I) c; void* delPtr = cast(void*) del(c); assert(cPtr != iPtr); assert(cPtr != delPtr); // fails assert(iPtr == delPtr); // fails } // Incorrect implicit conversion example static assert(!__traits(compiles, f(delegate C(C c) { return c; }))); // fails void main() { // As a result wrong code is generated for lambdas f(c => c); // creates delegate C(C), not I(C) } ---
Comment #1 by k.hara.pg — 2014-05-24T05:03:03Z
Comment #2 by github-bugzilla — 2014-05-31T21:15:24Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/0c17ec66daa5a16dd8012685c37e4a775b1d8c1a fix Issue 10219 - Implicit conversion between delegates returning a class and an interface https://github.com/D-Programming-Language/dmd/commit/3282cc306b36eeff34ea616b243058d0d0ab0e8d Merge pull request #3576 from 9rnsr/fix10219 Issue 10219 - Implicit conversion between delegates returning a class and an interface