[swift-evolution] union types

David Hart david at hartbit.com
Sat Dec 12 07:10:57 CST 2015


Type-erasure to the rescue? Links back to our twitter discussions Joe.
David.

> On 12 Dec 2015, at 04:53, Joe Groff via swift-evolution <swift-evolution at swift.org> wrote:
> 
>> 
>> On Dec 11, 2015, at 7:48 PM, Drew Crawford <drew at sealedabstract.com <mailto:drew at sealedabstract.com>> wrote:
>> 
>> 
>>> On Dec 11, 2015, at 9:01 PM, Joe Groff <jgroff at apple.com <mailto:jgroff at apple.com>> wrote:
>>> 
>>> with its Product type generalized to Any. 
>> 
>> 
>> In the alternate example
>> 
>> protocol Factory {
>>     typealias Product: ProductProtocol
>>     func make() -> Product
>>     var description : String { get }
>> }
>> 
>> would it generalize to ProductProtocol (e.g. not Any)?
> 
> Yeah, when generalizing a protocol type, we ought to be able to either generalize the associated types to their upper bounds, for use cases like yours, or constrain them to specific types, for the AnyGenerator<T> kind of case.
> 
> -Joe
>  _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151212/de1cd806/attachment.html>


More information about the swift-evolution mailing list