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: [email protected]
        ReportedBy: [email protected]


--- Comment #0 from Matt Kline <[email protected]> 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: -------

Reply via email to