[swift-evolution] [Proposal draft] Conditional conformances

Jordan Rose jordan_rose at apple.com
Tue Sep 27 19:06:38 CDT 2016


Great job thinking this all through (as usual), and I’ll be very happy to have Optional and Array become Equatable. Here’s some of my thoughts on the library evolution aspect of this:

- Removing a conditional conformance isn’t allowed, obviously.
- Adding a conditional conformance is just like adding an unconditional conformance—it needs availability info.
- It would be nice™ if making a conditional conformance more general was allowed. Since the plan doesn't allow overlapping conformances, I think this is actually implementable: just don’t put the constraints in the symbol name. I don’t know how to represent the backwards-deploying aspects of this right now, so it probably makes sense to forbid it today, but I think it would be nice if the implementation left the door open.

On that note, what happens here?

// Module Lib
public protocol Base {}
public protocol Sub: Base {}
public protocol Special: Sub {}

public struct Impl<T> {}
extension Impl: Special where T: Special {}


// Module Client
import Lib

extension Impl: Sub where T: Sub {}

I think this gets rejected because Impl already has a conformance to Sub—the extension in Client, despite being less specialized, shows up too late to actually declare this conformance “better”. Is that correct?

Jordan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160927/ee3a63f1/attachment.html>


More information about the swift-evolution mailing list