<div dir="ltr">I brought this up on Swift Dev and was told to check on Swift Evolution to see if a proposal is needed.<div><br></div><div>Currently, the following code produces a compiler error:</div><div><br></div><div><font face="monospace, monospace">func foo(_ x: Int, _ y: Int) -&gt; Int {</font></div><div><font face="monospace, monospace">  return x + y</font></div><div><font face="monospace, monospace">}</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">extension Int {</font></div><div><font face="monospace, monospace">  func foo() -&gt; Int {</font></div><div><font face="monospace, monospace">    return foo(self, self)    // Error here</font></div><div><font face="monospace, monospace">  }</font></div><div><font face="monospace, monospace">}</font></div><div><br></div><div>Notice that the two functions named “foo” have entirely different signatures. The global function takes 2 arguments, while the member function takes 0 (or 1, if referenced as “Int.foo”).</div><div><br></div><div>There is exactly one function “foo” which takes 2 arguments, so a call to “foo” with 2 arguments, like the one shown, should be unambiguous. However, instead of calling the function with matching signature, there is instead a compiler error.</div><div><br></div><div>This is already documented as <a href="https://bugs.swift.org/browse/SR-2450">SR–2450</a>, with an example from the standard library (global 2-argument “min” vs. 0-argument “Collection.min”).</div><div><br></div><div>It appears that in any situation where a global function and a member function share the same base name, but only the global function’s signature matches the call site, the result is a compiler error.</div><div><br></div><div>I suggest that, when there is exactly one function available with the proper name and signature, instead of a compiler error the matching function should be called.</div><div><br></div><div>Do we need a Swift Evolution proposal for this change?</div><div><br></div><div>Nevin</div></div>