May 18, 2011 [Issue 6028] New: Cannot implicitly convert an array of class to an array of interface | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=6028 Summary: Cannot implicitly convert an array of class to an array of interface Product: D Version: D2 Platform: Other OS/Version: Mac OS X Status: NEW Keywords: rejects-valid Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: kennytm@gmail.com --- Comment #0 from kennytm@gmail.com 2011-05-18 09:12:23 PDT --- Test case: ---------------------------- interface X {} class K : X {} class L : K {} void main() { L[] x; K[] y = x; // ok X[] z = y; // error } ---------------------------- test.d(8): Error: cannot implicitly convert expression (y) of type K[] to X[] ---------------------------- It should be possible to implicitly convert an array of class to an array of (one of) its base interface type. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 18, 2011 [Issue 6028] Cannot implicitly convert an array of class to an array of interface | ||||
---|---|---|---|---|
| ||||
Posted in reply to kennytm@gmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=6028 Steven Schveighoffer <schveiguy@yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |schveiguy@yahoo.com Resolution| |INVALID --- Comment #1 from Steven Schveighoffer <schveiguy@yahoo.com> 2011-05-18 10:13:59 PDT --- Actually, you shouldn't be able to convert either. See issue 2095 Though converting from a class array to an interface array is even worse -- an interface reference is not the same address of a class reference. So this implicit cast would not only have to rewrite all the elements, it would corrupt the original array. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation