<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Oct 6, 2016, at 7:31 AM, Mark Lacey <<a href="mailto:mark.lacey@apple.com" class="">mark.lacey@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Oct 6, 2016, at 4:53 AM, Toni Suter 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=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi,<div class=""><br class=""></div><div class="">Does someone know a good explanation / summary of Swift's overload resolution rules?</div><div class="">After reading <a href="https://github.com/apple/swift/blob/master/docs/TypeChecker.rst" class="">https://github.com/apple/swift/blob/master/docs/TypeChecker.rst</a> I understand</div><div class="">that the overloading resolution happens as part of the constraint solving step in the type </div><div class="">checker, but maybe there's a document somewhere, that explains the rules in more detail?</div></div></div></blockquote><div class=""><br class=""></div>I don’t know of any existing documentation for overload resolution. I was hoping to find some time to write something up in the next few months, but I’m not sure exactly when I might get to it.<br class=""></div><div class=""><br class=""></div><div class="">In the meantime the best advice I can give is to dig into the code a bit to understand what’s going on. The type checker runs the constraint solver and collections</div></div></div></blockquote><div><br class=""></div><div>^^^ collects</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""> all applicable solutions, and then compares these solutions to find a winner. That step is done in ConstraintSystem::findBestSolution() in CSRanking.cpp. That calls into ConstraintSystem::compareSolutions(), which is where most of the specific logic is. It checks overloads, and then checks the specific type bindings in each solution.</div><div class=""><br class=""></div><div class="">That code is reasonably well documented, so even without knowing a lot about the compiler internals I think it shouldn’t be too hard to follow.</div><div class=""><br class=""></div><div class="">Mark</div><div class=""><br class=""></div><br class=""></div></div></blockquote></div><br class=""></body></html>