[swift-users] Overload Resolution
Mark Lacey
mark.lacey at apple.com
Thu Oct 6 09:32:42 CDT 2016
> On Oct 6, 2016, at 7:31 AM, Mark Lacey <mark.lacey at apple.com> wrote:
>
>
>> On Oct 6, 2016, at 4:53 AM, Toni Suter via swift-users <swift-users at swift.org <mailto:swift-users at swift.org>> wrote:
>>
>> Hi,
>>
>> 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 <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?
>
> 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
^^^ collects
> 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.
>
> Mark
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20161006/2c76afbf/attachment.html>
More information about the swift-users
mailing list