[swift-dev] Making a protocol's associated type concrete via inheritance
swift at lng.la
swift at lng.la
Sun Aug 27 16:49:18 CDT 2017
Apologies for any terminology that I'm not using correctly, but I'm wondering if there's any way to make this work in Swift 4:
```
protocol P1 {
associatedtype Thing
func makeThing() -> Thing
}
protocol P2: P1 where Thing == String {}
func test(_ p2: P2) { // Can only use P2 as a generic constraint even though P2.Thing should be known to be String
print(p2.makeThing())
}
```
I want P2 to conform to P1 and make its associated type concrete so that it can be used directly. If this isn't possible right now, are there any plans for something like this to be added in the future? I've looked through the generics manifesto, but I didn't see anything that seemed to address this issue.
Thanks!
Jarod
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20170827/952f22b8/attachment.html>
More information about the swift-dev
mailing list