I've been upgrading code to support iOS 10 and migrating it to Swift 2.3 and ran into an issue with this line of code:
typealias CompositeType = protocol<Interface1, Interface2, Interface3>Xcode 8.0 beta 4 complains with a warning, saying 'protocol<…>' composition syntax is deprecated; join the protocols using '&'. It offers to make the change for me, converting the line to this:
typealias CompositeType = Interface1 & Interface2 & Interface3But this new code generates a series of compiler errors:
- Expressions are not allowed at the top level
- '&' is not a prefix unary operator
- Consecutive statements on a line must be separated by ';'
- Unary operator cannot be separated from its operand
I see from the Swift 3.0 CHANGELOG that SE-0095[1] replaces the protocol<> syntax. However, with Gmane offline it's difficult to find the discussion and see what alternative syntax I should be using, or if this use case was missed and protocol composition is broken in 2.3.
Has anyone else run into this, and know of a solution short of refactoring my types to avoid composition?
[1] https://github.com/apple/swift-evolution/blob/master/proposals/0095-any-as-existential.md
rdar://27661507