<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="" applecontenteditable="true"><div class="">It's a longstanding bug, but a bug we can't fix easily, and one whose fix would probably break user code. It's tracked by <a href="https://bugs.swift.org/browse/SR-3908" class="">SR-3908</a>. (The description's a little different but it's the same underlying issue.)</div><div class=""><br class=""></div><div class="">Jordan</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 19, 2017, at 22:13, Howard Lovatt via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi,<div class=""><br class=""></div><div class=""><span style="font-size:12.8px" class="">If I have the *same* extension in two *different* modules, ModuleA and ModuleB, and ModuleC uses both modules, but in *seperate* files, then there is still ambiguity about which extension to call:</span><div style="font-size:12.8px" class=""><br class=""></div><blockquote style="font-size:12.8px;margin:0px 0px 0px 40px;border:none;padding:0px" class="">ModuleA<br class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">A.swift</blockquote><span class="gmail-im"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">public protocol P {</blockquote></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">func m() -> String</blockquote></blockquote></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">}<br class=""></blockquote></blockquote></span><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">extension Int: P {</blockquote></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">public func m() -> String { <span style="font-size:12.8px" class="">return "AP.m" </span><span style="font-size:12.8px" class="">}</span></blockquote></blockquote></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">}<br class=""></blockquote></blockquote></blockquote><blockquote style="font-size:12.8px;margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""></blockquote>ModuleB<br class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""></blockquote>B.swift<br class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><span class="gmail-im">public protocol P {<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">func m() -> String</blockquote>}<br class=""></span>extension Int: P {<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">public func m() -> String { <span style="font-size:12.8px" class="">return "BP.m" </span><span style="font-size:12.8px" class="">}</span></blockquote>}<br class=""></blockquote></blockquote></blockquote><blockquote style="font-size:12.8px;margin:0px 0px 0px 40px;border:none;padding:0px" class="">ModuleC<br class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">A.swift</blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">import ModuleA</blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">func am(_ i: Int) -> String { return i.m() }<br class=""></blockquote></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">B.swift<br class=""></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">import ModuleB</blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">func bm(_ i: Int) -> String { return i.m() }<br class=""></blockquote></blockquote></blockquote><blockquote style="font-size:12.8px;margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">main.swift<br class=""></blockquote></blockquote><blockquote style="font-size:12.8px;margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""></blockquote></blockquote>let i = 0<br class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""></blockquote></blockquote>print(am(i))<br class="">print(bm(i))<br class=""></blockquote></blockquote></blockquote><br style="font-size:12.8px" class=""><span style="font-size:12.8px" class="">Gives the following errors when built:</span><br style="font-size:12.8px" class=""><div style="font-size:12.8px" class=""><br class=""></div><blockquote style="font-size:12.8px;margin:0px 0px 0px 40px;border:none;padding:0px" class="">sunzero-ln:ModuleC lov080$ swift build<br class="">Fetching /Users/lov080/Google Drive/Swift/Examples/Example Module Clashes/ModuleA<br class="">Fetching /Users/lov080/Google Drive/Swift/Examples/Example Module Clashes/ModuleB<br class="">Cloning /Users/lov080/Google Drive/Swift/Examples/Example Module Clashes/ModuleA<br class="">Resolving /Users/lov080/Google Drive/Swift/Examples/Example Module Clashes/ModuleA at 1.0.0<br class="">Cloning /Users/lov080/Google Drive/Swift/Examples/Example Module Clashes/ModuleB<br class="">Resolving /Users/lov080/Google Drive/Swift/Examples/Example Module Clashes/ModuleB at 1.0.0<br class="">Compile Swift Module 'ModuleB' (1 sources)<br class="">Compile Swift Module 'ModuleA' (1 sources)<br class="">Compile Swift Module 'ModuleC' (3 sources)<br class="">/Users/lov080/Google Drive/Swift/Examples/Example Module Clashes/ModuleC/Sources/B.<wbr class="">swift:3:38: error: ambiguous use of 'm()'<br class="">func bm(_ i: Int) -> String { return i.m() }<br class=""> ^<br class="">ModuleA.Int:2:17: note: found this candidate<br class=""> public func m() -> String<br class=""> ^<br class="">ModuleB.Int:2:17: note: found this candidate<br class=""> public func m() -> String<br class=""> ^<br class="">/Users/lov080/Google Drive/Swift/Examples/Example Module Clashes/ModuleC/Sources/A.<wbr class="">swift:3:38: error: ambiguous use of 'm()'<br class="">func am(_ i: Int) -> String { return i.m() }<br class=""> ^<br class="">ModuleA.Int:2:17: note: found this candidate<br class=""> public func m() -> String<br class=""> ^<br class="">ModuleB.Int:2:17: note: found this candidate<br class=""> public func m() -> String<br class=""> ^<br class=""><unknown>:0: error: build had 1 command failures<br class="">error: exit(1): /Applications/Xcode.app/<wbr class="">Contents/Developer/Toolchains/<wbr class="">XcodeDefault.xctoolchain/usr/<wbr class="">bin/swift-build-tool -f /Users/lov080/Google\ Drive/Swift/Examples/Example\ Module\ Clashes/ModuleC/.build/debug.<wbr class="">yaml<br class=""><br class=""></blockquote><span style="font-size:12.8px" class="">Is this the expected behaviour or a bug?</span></div><div class=""><span style="font-size:12.8px" class=""><br class=""></span></div><div class=""><span style="font-size:12.8px" class="">Thanks in advance for any help,</span></div><div class=""><span style="font-size:12.8px" class=""><br clear="all" class=""></span><div class=""><div class="gmail_signature"> -- Howard.<br class=""></div></div>
</div></div>
_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></body></html>