[swift-users] Weird protocol behaviour.

Guillaume Lessard glessard at tffenterprises.com
Thu Dec 22 16:12:51 CST 2016

The function foo<A: P>(x: A){} requires a type which conforms to protocol P.

An existential of protocol P does not actually conform to protocol P.
It’s always been a limitation in Swift: https://bugs.swift.org/browse/SR-55

If the function’s signature were foo(x: P){}, it would work.

Howard’s example swaps the protocol P for a concrete type (P1), which is what makes it work.

Guillaume Lessard

More information about the swift-users mailing list