[swift-users] Multiple Class Types in Protocol Composition

Mario Meili mario.meili at live.com
Fri Dec 8 02:22:03 CST 2017


Hi Slava,

Thank you very much for the quick response. As you requested, I filed the bug under the following link: https://bugs.swift.org/browse/SR-6561

Best Regards
Mario

From: <spestov at apple.com> on behalf of Slava Pestov <spestov at apple.com>
Date: Thursday, 7 December 2017 at 22:27
To: Mario Meili <mario.meili at live.com>
Cc: "swift-users at swift.org" <swift-users at swift.org>
Subject: Re: [swift-users] Multiple Class Types in Protocol Composition

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<mailto: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://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fapple%2Fswift-evolution%2Fblob%2Fmaster%2Fproposals%2F0156-subclass-existentials.md&data=02%7C01%7C%7Cf12145f448334d2a644c08d53db941d1%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636482788230444913&sdata=bjKRAVds%2BubJz5Mpi27bQmpbBigAfekf%2FiXopHekabE%3D&reserved=0>), 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://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.swift.org%2Fmailman%2Flistinfo%2Fswift-users&data=02%7C01%7C%7Cf12145f448334d2a644c08d53db941d1%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636482788230444913&sdata=pY7NkpjW9jmvnhjXYa3axI%2F631OaDOdJ0F4KsIb%2FXHI%3D&reserved=0>

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


More information about the swift-users mailing list