<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><br><br><div id="AppleMailSignature">Sent from my iPhone</div><div><br>On Dec 18, 2017, at 6:27 PM, Dave Abrahams <<a href="mailto:dabrahams@apple.com">dabrahams@apple.com</a>> wrote:<br><br></div><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Dec 18, 2017, at 4:52 PM, Douglas Gregor via swift-dev <<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi all,<div class=""><br class=""></div><div class="">A little while back, I added an error to the Swift 4.1 compiler that complains if one tries to use conditional conformances, along with a flag “-enable-experimental-conditional-conformances” to enable the feature. We did this because we haven’t implemented the complete proposal yet; specifically, we don’t yet handle dynamic casting that involves conditional conformances, and won’t in Swift 4.1.</div><div class=""><br class=""></div><div class="">I’d like to take away the "-enable-experimental-conditional-conformances” flag and always allow conditional conformances in Swift 4.1, because the changes in the standard library that make use of conditional conformances can force users to change their code *to themselves use conditional conformances*. Specifically, if they had code like this:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Menlo" class="">extension MutableSlice : P { }</font></div><div class=""><font face="Menlo" class="">extension MutableBidirectionalSlice : P { }</font></div><div class=""><font face="Menlo" class="">// …</font></div></blockquote><div class=""><br class=""></div><div class="">they’ll get an error about overlapping conformances, and need to do something like the following to fix the issue:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Menlo" class="">extension Slice: P where Base: MutableCollection { }</font></div></blockquote><div class=""><br class=""></div><div class="">which is way more elegant, but would require passing "-enable-experimental-conditional-conformances”. That seems… unfortunate… given that we’re forcing them to use this feature.</div><div class=""><br class=""></div><div class="">My proposal is, specifically:</div><div class=""><br class=""></div><div class=""><ul class="MailOutline"><li class="">Allow conditional conformances to be used in Swift 4.1 (no flag required)</li><li class="">Drop the -enable-experimental-conditional-conformances flag entirely</li><li class="">Add a runtime warning when an attempt to dynamic cast fails due to a conditional conformance, so at least users know what’s going on</li></ul></div><div class=""><br class=""></div><div class="">Thoughts?</div></div></div></blockquote><div><br class=""></div>I'm confused; I thought that overlapping conformances could result in cases where it's ambiguous which extension to use to satisfy a requirement, but I don't see anything in your proposal for handling that. Does that become a dynamic failure?</div></blockquote><br><div>My proposal doesn’t handle that. I guess I was unclear: the first code snippet, which is well-formed in Swift 4, will get an “overlapping conformance” error in Swift 4.1. It’s a source compatibility break, but one we feel is necessary. </div><div><br></div><div>The fixed code only has a single (conditional) conformance, so there’s nothing to overlap. </div><div><br></div><div> - Doug</div><div><br></div></body></html>