[swift-evolution] Warning on name collisions with functions in protocol extensions

Brian King brianaking at gmail.com
Thu Apr 6 12:26:22 CDT 2017


Has there been any conversation around generating a warning if a type
implements a function that is also implemented in an extension of a
conforming protocol? This is a frequent source of confusion for new swift
developers, and I think the reaction to this behavior is more severe than
it needs to be because the compiler does not help identify or explain the
nuance.

My gut feeling is that intended (or required) function collisions are very
rare. I think forcing the user to rename the colliding function would work
most of the time. The language could have an attribute like
`@iMeantToCollideFunctions` to disable the warning when it was intended,
although no good name for this attribute comes to mind. It feels like there
needs to be some way to disable the warning when the collision is accepted,
even if it is a rare use case. Colliding functions could also be not
supported, just like conforming to 2 protocols with colliding default
implementations.

Anyway, I'm not sure if this has been discussed and dismissed already. I've
been having fun exploring compiler warnings to help developers avoid
dispatch confusion, and was interested in what people thought.

Brian King
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170406/9e31303f/attachment.html>


More information about the swift-evolution mailing list