[swift-evolution] When exactly 1 function matches a call site, should it be called or cause a compiler error?
Nevin Brackett-Rozinsky
nevin.brackettrozinsky at gmail.com
Sun Nov 12 21:27:24 CST 2017
On Sun, Nov 12, 2017 at 10:16 PM, Slava Pestov <spestov at apple.com> wrote:
>
> Pardon my lack of imagination, but could you provide an example of a call
> site that would become ambiguous?
>
>
> protocol P {}
> protocol Q {}
> struct S : P, Q {}
>
> struct Outer {
> static func foo(_: P) {}
>
> struct Inner {
> static func foo(_: Q) {}
>
> static func bar() {
> foo(S())
> }
> }
> }
>
Resolves to Inner.foo just like it does today.
We would still start from the innermost scope and work our way outward
until we find a match. The only difference is we no longer stop partway up
the chain *without* finding a match.
If we do find a match then yes, of course we stop there and use it.
Nevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171112/48c5e0d2/attachment.html>
More information about the swift-evolution
mailing list