mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Previously, SILGen assumed that a foreign function could either have a
foreign async convention or a foreign error convention, but if it had
both, the error would be subsumed into the completion. That resulted in
failures to emit code for async calls of functions like
```
- (BOOL)minimalWithError:(NSError* _Nullable*)error
completionHandler:(void (^ _Nonnull)(void))completionHandler;
```
Here, SILGen gains the ability to emit such functions. To enable that,
a few changes were required when both conventions are present:
- a separate argument for each convention is used
- the ResultPlan is a ForeignErrorResultPlan nesting a
ForeignAsyncResultPlan
- the continuation is always of the form UnsafeContinuation<_, Error>
regardless of whether the completion handler takes an error
- the foreign error block fills the continuation with the error that was
passed by reference out of the ObjC method call
- the foreign error block branches to the block containing the await
instruction
rdar://80704984
25 lines
1011 B
Objective-C
25 lines
1011 B
Objective-C
#include <Foundation/Foundation.h>
|
|
|
|
#pragma clang assume_nonnull begin
|
|
|
|
@interface PFXObject : NSObject {
|
|
}
|
|
- (BOOL)failReturnWithError:(NSError *_Nullable *)error
|
|
completionHandler:
|
|
(void (^_Nonnull)(NSError *_Nullable error))completionHandler;
|
|
- (BOOL)failInvokeSyncWithError:(NSError *_Nullable *)error
|
|
completionHandler:
|
|
(void (^_Nonnull)(NSError *_Nullable error))completionHandler;
|
|
- (BOOL)failInvokeAsyncWithError:(NSError *_Nullable *)error
|
|
completionHandler:(void (^_Nonnull)(NSError *_Nullable error))
|
|
completionHandler;
|
|
- (BOOL)succeedSyncWithError:(NSError *_Nullable *)error
|
|
completionHandler:
|
|
(void (^_Nonnull)(NSError *_Nullable error))completionHandler;
|
|
- (BOOL)succeedAsyncWithError:(NSError *_Nullable *)error
|
|
completionHandler:
|
|
(void (^_Nonnull)(NSError *_Nullable error))completionHandler;
|
|
@end
|
|
|
|
#pragma clang assume_nonnull end
|