protocol FooProtocol {
func doAThing(using: String)
}
struct ConformsUsingClosure: FooProtocol {
var doAThing: (String)->Void = { print($0) }
}
let instance = ConformsUsingClosure()
instance.doAThing("where did my label go?")
let erasedInstance: FooProtocol = instance
erasedInstance.doAThing(using: "Okay, now we get a label?")
Since closures don't support argument labels, we'd have to drop the "using:" label when invoking the function in a concrete context. I asked about adding support for this before, and the consensus was that dropping the argument labels was not acceptable (so it's not a technical limitation - it's just something we don't want to support until we can preserve the labels).
If we could instead write this:
struct ConformsUsingClosure: FooProtocol {
var doAThing: (using: String)->Void = { print($0) }
}
Then we get a nice, consistent calling syntax, and there shouldn't be any objection to allowing the closure to witness the function requirement.