This might be a more general issue related to stuffing a whole function into a single generic placeholder and then stuffing that into the param of another function:
func putInParam<T>(_ x: T) -> (T)->Void {
return { (_: T)->Void in }
}
type(of: putInParam({ (_: String)->Void in }))
//> ((String) -> ()) -> ()
putInParam({ (_: String)->Void in }) is ((String) -> ()) -> ()
//> false
Giving it a non-function works fine:
putInParam("foo") is (String) -> ()
//> true
Or putting it into the return instead of the params also works:
func putInReturn<T>(_ x: T) -> ()->T {
return { return x }
}
putInReturn({ (_: String)->Void in }) is () -> (String) -> ()
//> true
It feels like I'm missing some subtlety of the type syntax. Like by wrapping a function in parens to indicate it's the parameter of another function, I'm accidentally asking swift to treat it like a tuple or something.
In short: you have to use a little helper function (with a cool name zurry) that lowers a function that takes no arguments to just the value that it returns.