SR-9392 The swift_error attribute can not be applied to function or block typedefs
Issue Description:
Currently, rethrowing functions cannot be exported to Objective-C, even if all types are Obj-C compatible. Furthermore, a throwing closure type cannot be marked as @convention(block), citing that the type is not representable.
This limits the ability to propagate errors when wanting to export for Objective-C, or implementing the same in Objective-C for locking, queueing, etc. One might expect the block type to get exported with the same (…, NSError **) -> BOOL expansion functions themselves are. Consider the following signature, inspired by NSDocument:
The same desire applies in reverse; I should be able to implement -performSynchronousAccessAndReturnError:block: from Objective-C. One might expect the full gamut of the swift_error attribute to apply to block and function parameters, if not blocks and functions as a whole.
Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 1 | |Component/s | Compiler | |Labels | Improvement, ClangImporter, PrintAsObjC | |Assignee | None | |Priority | Medium | md5: 290e334cda7650c06f329c05489b169frelates to:
Issue Description:
Currently, rethrowing functions cannot be exported to Objective-C, even if all types are Obj-C compatible. Furthermore, a throwing closure type cannot be marked as
@convention(block)
, citing that the type is not representable.This limits the ability to propagate errors when wanting to export for Objective-C, or implementing the same in Objective-C for locking, queueing, etc. One might expect the block type to get exported with the same
(…, NSError **) -> BOOL
expansion functions themselves are. Consider the following signature, inspired byNSDocument
:It should be imported into Objective-C approximately (there are some weirdnesses with the parameter names) as:
The same desire applies in reverse; I should be able to implement
-performSynchronousAccessAndReturnError:block:
from Objective-C. One might expect the full gamut of theswift_error
attribute to apply to block and function parameters, if not blocks and functions as a whole.