It's not just Objective-C interoperability. It'll happen in Swift for the same reasons when someone adds async
versions alongside existing completion-handler APIs (of which there are many):
func post(_ data: Data, to url: URL, completionHandler: ((Response) -> Void)? = nil) { ... }
func post(_ data: Data, to url: URL) async { ... }
Note that this is allowed even with the proposed change, because post(_:to:completionHandler:)
and post(_:to:)
have different method names and signatures even ignoring the async
. Without overload resolution rules like the ones proposed, the expression post(data, to: url)
will always resolve to the async
version, breaking existing code.
I promise to write up a detailed discussion of this, because we went pretty far down the design and implementation path for removing overloading before deciding that we needed overloading still.
Doug