<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 10, 2017, at 12:41 PM, Robert Ryan via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div></blockquote><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I’m hard pressed to think of a situation where you’d want the current Swift 3 behavior of the first example (where you can override a protocol default implementation but you only want that override used when you reference the class itself, but not when you reference the protocol as a type). </div></div></div></blockquote><div><br class=""></div>Thats easy - the extension methods are not related to protocol conformance. The type implementing the protocol may not even know there *is* an extension method, or that method could be added either later or by yet other third party code. </div><div><br class=""></div><div>As such, the type may not be overriding the extension method at all - the protocol-implementing types may have their own method with a conflicting name doing similar (or not) logic. It would not be appropriate for someone calling the protocol extension method to get different behavior simply because a type declared a similar named method.</div><div><br class=""></div><div>In other words, without the method being declared on the protocol, override behavior between an extension and type would be similar to unsafe “duck” typing. There is no agreement by the type that they are conforming to extension behavior, only to the protocol’s behavior.</div><div><br class=""></div><div>IMHO the issue actually goes the other way</div><div> - there is no way to indicate that an extension method to a protocol is meant to declare ‘default’ behavior, e.g. represents a partial implementation for types conforming to the protocol.</div><div> - there is no way to indicate that a type property/method ‘implements’ the functionality of a protocol. </div><div><br class=""></div><div>The lack of a distinction between extensions declaring random methods and declaring default implementation behavior is obviously an element of confusion. Both points become an issue if the protocol method signatures ever changes - the extension could no longer be providing a default implementation, or a type may silently switch from their own implementation to the default implementation provided by the extension.</div><div><br class=""></div><div>-DW</div><div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">If there are such examples, then add a “build setting” to allow you to turn off this warning, or add some keyword to the declaration of the default implementation that indicates that you’re allowing it to be overridden, but protocol types won’t use it (e.g. <span style="color: rgb(186, 45, 162); font-family: Menlo; font-size: 11px;" class="">nondynamic</span>). Personally, I’d just add the warning and call it a day (because I don’t know why you’d ever want the current Swift 3 behavior).</div><div class=""><br class=""></div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>