This is not related to selectors. You're just typing the closure incorrectly.
#selector(URLSessionDataDelegate.urlSession as (_) -> ((_, _, URLSessionDownloadTask) -> _)?)
Swift now supports references to optional methods on a protocol metatype, as well as references that are dynamically looked up on the AnyObject metatype. These references always have the type of a function that accepts a single argument and returns an optional value of function type:
I tried to give some thought to how this recommendation is different than, "never use implicit typing, because there is no way to mark overloads as frozen". Is it different? I don't recall hearing that guideline before.
A (non-generic) method is uniquely identified by the combination of its full name and argument types (…and return type, but let’s pretend people don’t do that). If you leave out the labels, you’re relying on nobody defining another method with the same base name and argument types; if you leave out the types, you’re relying on nobody defining another method with the same full name. Neither is futureproof but in practice for Cocoa-style delegate methods you’re more likely to see “different labels, same types” than you are to see “same labels, different types”.
I think I disagree; compilation fails with Ambiguous use at the time a new overload is introduced.
E.g.
struct S {
init(_: Int) { }
}
(0...1).map(S.init) // Fine until next year, when…
extension S {
init(newOverload: Int) { }
}
What you're suggesting seems like a slippery slope towards elimination of implicit typing, to me, but I'm guessing you have some kind of guideline internalized that isn't so extreme. I just don't think I've heard it before.