[swift-users] Protocol conformance failure

Guillaume Lessard glessard at tffenterprises.com
Thu Mar 9 15:10:06 CST 2017

> On Mar 9, 2017, at 12:46, Edward Connell via swift-users <swift-users at swift.org> wrote:
> // Everything compiles fine until this
> someFunc(items: items)

This is a frequent pain point: protocol existentials cannot stand in for the protocol they represent.
Your function wants a concrete type that conforms to ItemProtocol, but an array of disparate types which happen to separately conform to ItemProtocol does not do that.

You will need to overload thusly:

func someFunc(items: [ItemProtocol]) {
  for item in items {

until, someday, this pain point is resolved.

Guillaume Lessard

More information about the swift-users mailing list