[swift-users] Multiple Class Types in Protocol Composition

Slava Pestov spestov at apple.com
Thu Dec 7 15:26:59 CST 2017


Hi Mario,

You’re right that this part of the proposal was not fully implemented. Computing the common ancestor of two superclasses is a little tricky here because it would force us to resolve the superclass type of a class when realizing a subclass existential. This would introduce circular dependencies. Either I missed something obvious or it would require some re-architecting of the type checker to make it work.

Either way, yes it’s a known limitation, but not one that is tracked by a JIRA presently, so please do file a bug!

Thanks,

Slava

> On Dec 7, 2017, at 7:17 AM, Mario Meili via swift-users <swift-users at swift.org> wrote:
> 
> Hi everyone,
>  
> I noticed strange behaviour of the Swift 4.0.3 compiler regarding class and subtype existentials.
>  
> According to the proposal SE-0156 (https://github.com/apple/swift-evolution/blob/master/proposals/0156-subclass-existentials.md <https://github.com/apple/swift-evolution/blob/master/proposals/0156-subclass-existentials.md>), multiple class types in protocol compositions should be allowed, if:
>  
> The class types are the same
> Or, one class type must be a subtype of the other.
>  
> However, when copying the exact code from the proposal into Xcode 9.2, the result is the following:
>  
> <image001.png>
>  
> My conclusion here is that the compiler does not allow multiple class types in one protocol composition.
>  
> My question is:
> Is this behaviour intended or should I open a bug report?
>  
> Thank you very much
>  
> BR
> Mario
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org <mailto:swift-users at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-users <https://lists.swift.org/mailman/listinfo/swift-users>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20171207/ce729ddb/attachment.html>


More information about the swift-users mailing list