[swift-evolution] Enhanced existential types proposal discussion

Adrian Zubarev adrian.zubarev at devandartist.com
Fri May 20 08:02:34 CDT 2016


Can we use `Any<…>` for protocol conformance like this: 

protocol A: Any<class> {} <— this makes a little sense, but I’d rather write protocol A: class {} instead

protocol B: Any<UIView, SomeProtocol>  <— this is confusing. One could argue we could apply B only on any UIView subclass which conforms to SomeProtocol, but why can’t we do also this: protocol C: Any<UIView> 

One downside here is that `Any<UIView> == UIView` and should be banned because its redundant.

We cannot write something like this:

protocol C: UIView 

Or can we?

I’d propose we should ban this in Swift 3. 
This implies that `typealias AnyObject = Any<class>` won’t work anymore on protocols. This is a breaking change. 
I’d write a small proposal as another follow up to SE-0095 if my thoughts are right.

-- 
Adrian Zubarev
Sent with Airmail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160520/abc0c7cf/attachment.html>


More information about the swift-evolution mailing list