You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SR-27 Passing variadic function as a function parameter crashes compiler with SIGSEGV
Issue Description:
Swift 2.2 covariance unable to resolve functions covariance with variadic arguments.
Steps to Reproduce:
Attached a playground that shows the problem, as well as screenshot with errors. Here is a copy & paste of the code for your convenience:
funcgiveMeVoid(callback: (Void)->Void) {
}
funcgiveMeInt(callback: (Int)->Void) {
}
funcany(values:Any?...) {
}
any()
any(5)
giveMeVoid(any) //This line will failgiveMeInt(any) //This line will fail
Expected Results:
It is expected that `any` will be accepted by both giveMeVoid and giveMeInt functions, as they can work as `Void` and `Int` functions when they called directly.
Actual Results:
Non of functions accept 'any'. Following errors are thrown:
This is not a variance issue, this is an implicit coercion that you're asking for. We would need to add additional thunks to help with the wrapping here. @rjmccall how feasible is something like this?
We're not really set up for it; the subtype-conversion logic really wants to translate specific arguments, not completely rework them structurally. It could be fixed, though.
This is an interesting idea, but I'm not sure we want to generalize function conversions to apply to literally anything where you could forward the arguments this way.
Attachment: Download
Environment
Xcode 7.1.1 (7B1005)
Additional Detail from JIRA
md5: 1344eed40e3fc0135966b4277a47f007
relates to:
Issue Description:
Swift 2.2 covariance unable to resolve functions covariance with variadic arguments.
Steps to Reproduce:
Attached a playground that shows the problem, as well as screenshot with errors. Here is a copy & paste of the code for your convenience:
Expected Results:
It is expected that `any` will be accepted by both giveMeVoid and giveMeInt functions, as they can work as `Void` and `Int` functions when they called directly.
Actual Results:
Non of functions accept 'any'. Following errors are thrown:
The text was updated successfully, but these errors were encountered: