Xcode-beta (7A176x): If Swift supports type-erased protocols, allow generic Self constraint
| Originator: | david.w.hart | ||
| Number: | rdar://22231099 | Date Originated: | 11-Aug-2015 05:09 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode-beta (7A176x) |
| Classification: | Feature (New) | Reproducible: | Always |
Given a protocol with an associated type:
protocol Proto {
typealias T
let value: T { get }
init(value: T)
}
If Swift ever allows type-erasure:
let a: Proto<Int> = …
I’d like it if we could use Self generically:
extension Proto<T> {
func map<U>(transform: T -> U) -> Self<U> {
return Self.init(transform(self.value))
}
}
Like this, this map function could be defined to return the same type but with a different generic type.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!