[swift-evolution] Allow protocol vars to match derived types
Mark Anders
mark at markanders.net
Tue Mar 8 16:11:06 CST 2016
Thanks Joe, bug submitted!
Mark
On March 8, 2016 at 2:27:57 PM, Joe Groff (jgroff at apple.com) wrote:
On Mar 8, 2016, at 1:15 PM, Mark Anders via swift-evolution <swift-evolution at swift.org> wrote:
Slava/Joe, thanks for clarifying the issue and Slava for providing more depth on what needs to happen. Like David, I was unsure if this was just a bug or an enhancement.
Out of curiosity, you mention some related issues, and I just ran into something similar and wonder if it’s related too.
class A {}
class B : A {}
var arrayOfA = [A]()
let arrayOfB : [B] = [B()]
arrayOfA.appendContentsOf(arrayOfB)
This fails to compile, though doing arrayOfA.append(B()) works as I would expect.
This one seems like a plain bug to me, since it should be possible to convert arrayOfB to [A] and hand the [A] off to appendContentsOf.
-Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160308/f337ec0f/attachment.html>
More information about the swift-evolution
mailing list