[swift-evolution] Feature request/suggestion: object conforming to a protocol type

Adrian Zubarev adrian.zubarev at devandartist.com
Mon Nov 21 15:05:49 CST 2016

This is part of the existential types and a highly wanted feature. You can read more about here and here.

Adrian Zubarev
Sent with Airmail

Am 21. November 2016 um 22:01:33, Richard Henry via swift-evolution (swift-evolution at swift.org) schrieb:

Hopefully this is the right mailing list...

It seems like there’s currently no way to declare a type that is an object conforming to a protocol in Swift, and I think that would be a useful language feature to add.

To be super clear about what I mean, if I have the following code:

class MyClass {

protocol MyProtocol {

There is currently no way to do something like (in pseudo-code):

var thing: MyClass & MyProtocol = …

In Objective-C, you would do:

MyClass <MyProtocol> *thing ...

Is this up for consideration, or is there a reason why this isn’t possible? Thanks.

swift-evolution mailing list
swift-evolution at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161121/090a1dd9/attachment.html>

More information about the swift-evolution mailing list