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.
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 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.
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.
On Oct 6, 2016, at 4:53 AM, Toni Suter via swift-users <email@example.com> wrote:
Does someone know a good explanation / summary of Swift's overload resolution rules?
After reading https://github.com/apple/swift/blob/master/docs/TypeChecker.rst I understand
that the overloading resolution happens as part of the constraint solving step in the type
checker, but maybe there's a document somewhere, that explains the rules in more detail?