Cannot convert value of type '(@escaping () -> (), @escaping (Provider.Error) -> ()) -> ()' to expected argument type '(@escaping (Void) -> Void, @escaping (Provider.Error) -> Void) -> Void'
it seems the complier is expecting a (Void) a.k.a (()) for the onSuccess: part.
Is this expected or a bug? How to get it right if it is not a bug, excepting for changing onSuccess: @escaping () -> () to onSuccess: @escaping (()) -> () in Provider.execute?
This is expected: your type alias requires that the closure have one parameter of type Output, which you then specify to be Void, and this is not the same as having zero parameters. You will therefore need to provide a closure of type @escaping (()) -> ().
(Fortunately, closures themselves have a special rule such that you can pass as an argument a concrete closure expression which has no parameters.)
Do you mean a special overload like the following extension needs to be added in this case? Like what Combine does for PassthroughSubject with send(Output) and send() when Output is Void? But I remember I read it somewhere that the (()) to () is somewhat automatically supported in Swift?
This is not true. A function/closure with zero arguments is not the same as, nor can it be converted to, a function/closure with a single Void argument.
Here eventHandler is a function with zero arguments, which is converted to a closure with a single Void argument. It this wasn't the case, you'd have to write it like this: