[Issue 12283] New: Array literals of interface implementations do not resolve to interface
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Mar 1 15:16:16 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12283
Summary: Array literals of interface implementations do not
resolve to interface
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: mkline.on.d at gmail.com
--- Comment #0 from Matt Kline <mkline.on.d at gmail.com> 2014-03-01 15:16:12 PST ---
One would assume that, given an array literal of various implementations of an
interface, the compiler would reduce the literal to an array of that interface.
However, the following fails:
interface Inter {
}
class FooImpl : Inter {
}
class BarImpl : Inter {
}
void main()
{
Inter[] test = [new FooImpl(), new BarImpl()];
}
with
poly.d(12): Error: cannot implicitly convert expression (new FooImpl) of type
object.Object to poly.BarImpl
poly.d(12): Error: cannot implicitly convert expression ([(__error), new
BarImpl]) of type BarImpl[] to Inter[]
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list