www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12283] New: Array literals of interface implementations do not resolve to interface

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: mkline.on.d gmail.com


--- Comment #0 from Matt Kline <mkline.on.d 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: -------
Mar 01 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12283


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies gmail.com


--- Comment #1 from yebblies <yebblies gmail.com> 2014-03-02 19:25:55 EST ---
This has the same cause (and fix) as issue 5498.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 02 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12283


Matt Kline <mkline.on.d gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


--- Comment #2 from Matt Kline <mkline.on.d gmail.com> 2014-03-04 10:04:47 PST
---
*** This issue has been marked as a duplicate of issue 5498 ***

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 04 2014