Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-4718] Define property that conforms to a protocol #47295

Closed
swift-ci opened this issue Apr 27, 2017 · 3 comments
Closed

[SR-4718] Define property that conforms to a protocol #47295

swift-ci opened this issue Apr 27, 2017 · 3 comments
Labels
compiler The Swift compiler in itself duplicate Resolution: Duplicates another issue existentials Feature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased values feature A feature request or implementation protocol compositions Feature → types: protocol composition types swift evolution implemented Flag → feature: A feature that was approved through the Swift evolution process and implemented

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Apr 27, 2017

Previous ID SR-4718
Radar None
Original Reporter carmelo.gallo (JIRA User)
Type New Feature
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels New Feature
Assignee None
Priority Medium

md5: 7fb30aa97e7cd85d235158c3f33ef324

duplicates:

Issue Description:

Hi guys, I'm just wondering if is possible to have in the next release a way to define a property that conforms to a specific protocol.

e.g.

var view: UIView<SomeProtocol>
// or even multi protocol 
var view: UIView<SomeProtocol_1, SomeProtocol_2>

Is that possible?

I know that I can do the follow way

protocol SomeProtocol { }

class SomeProtocolView: UIView, SomeProtocol { }

class MyClass {
    var myView: SomeProtocolView!
}

but I would like to avoid subclassing.

Looking forward to your answer, cheers!

Carmelo

@belkadan
Copy link
Contributor

Yep, this is SE-0156!

@swift-ci
Copy link
Collaborator Author

Comment by Carmelo Gallo (JIRA)

@hi @belkadan, thanks for the heads up. However I can see that seems the structs are out of that implementation. Am I right?

@belkadan
Copy link
Contributor

That's correct. There's no need for it with a struct—either the struct conforms to the protocol, or it doesn't.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added duplicate Resolution: Duplicates another issue feature A feature request or implementation swift evolution implemented Flag → feature: A feature that was approved through the Swift evolution process and implemented existentials Feature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased values protocol compositions Feature → types: protocol composition types and removed new feature labels Jan 27, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself duplicate Resolution: Duplicates another issue existentials Feature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased values feature A feature request or implementation protocol compositions Feature → types: protocol composition types swift evolution implemented Flag → feature: A feature that was approved through the Swift evolution process and implemented
Projects
None yet
Development

No branches or pull requests

3 participants