[swift-evolution] Warning when "overriding" an extension method that's not in the protocol?

Douglas Gregor dgregor at apple.com
Fri Dec 11 17:33:57 CST 2015

> On Dec 10, 2015, at 3:13 PM, Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org> wrote:
>> If you've made it all the way through, I want to propose that we add a warning in case you override a protocol extension method that's visible in your scope (and has exactly the same type). For example, implementing `share()` in String could trigger a warning. In my experience, it's confusing that it looks like you're overriding it, but you're not really. I strongly believe the current behavior is correct, yet, it can be quite confusing, especially coming from ObjC.
> We’re actually discussing this for the last few days in the threads "Proposal: Require explicit modifier for statically dispatched extension methods” (newer) and "Proposal: Universal dynamic dispatch for method calls” (older). You might want to dig into the list archives and take a look at them. <https://lists.swift.org/pipermail/swift-evolution/>

FWIW, I consider adding a warning for this case to be a bug fix [*] that doesn’t need to go through the evolution process: it’s an area where users clearly get surprised, and even if we do end up making changes in Swift 3.0, we could help users of Swift 2 greatly in the interim.

	- Doug

[*] Not coincidentally, a bug has been on me for a long time to do this… sorry.

More information about the swift-evolution mailing list