File tree Expand file tree Collapse file tree 3 files changed +50
-4
lines changed Expand file tree Collapse file tree 3 files changed +50
-4
lines changed Original file line number Diff line number Diff line change 7
7
- (void )butt : (NSInteger )x completionHandler : (void (^ _Nonnull)(NSInteger ))handler ;
8
8
9
9
@end
10
+
11
+ @interface Farm : NSObject
12
+
13
+ -(void )getDogWithCompletion : (void (^ _Nonnull)(NSInteger ))completionHandler
14
+ __attribute__((swift_async_name(" getter:doggo()" )));
15
+
16
+ -(void )obtainCat : (void (^ _Nonnull)(NSInteger , NSError * _Nullable))completionHandler
17
+ __attribute__((swift_async_name(" getter:catto()" )));
18
+
19
+ @end
Original file line number Diff line number Diff line change @@ -13,3 +13,17 @@ - (void)butt:(NSInteger)x completionHandler:(void (^)(NSInteger))handler {
13
13
}
14
14
15
15
@end
16
+
17
+ @implementation Farm
18
+
19
+ -(void )getDogWithCompletion : (void (^ _Nonnull)(NSInteger ))completionHandler {
20
+ printf (" getting dog\n " );
21
+ completionHandler (123 );
22
+ }
23
+
24
+ -(void )obtainCat : (void (^ _Nonnull)(NSInteger , NSError * _Nullable))completionHandler {
25
+ printf (" obtaining cat has failed!\n " );
26
+ completionHandler (nil , [NSError errorWithDomain: @" obtainCat" code: 456 userInfo: nil ]);
27
+ }
28
+
29
+ @end
Original file line number Diff line number Diff line change 10
10
// rdar://76038845
11
11
// UNSUPPORTED: use_os_stdlib
12
12
13
- @main struct Main {
14
- static func main( ) async {
13
+ func buttTest( ) async {
15
14
let butt = Butt ( )
16
15
let result = await butt. butt ( 1738 )
17
16
print ( " finishing \( result) " )
17
+ }
18
+
19
+ func farmTest( ) async {
20
+ let farm = Farm ( )
21
+ let dogNumber = await farm. doggo
22
+ print ( " dog number = \( dogNumber) " )
23
+ do {
24
+ let _ = try await farm. catto
25
+ } catch {
26
+ print ( " caught exception " )
18
27
}
19
28
}
20
29
21
- // CHECK: starting 1738
22
- // CHECK-NEXT: finishing 679
30
+ @main struct Main {
31
+ static func main( ) async {
32
+ // CHECK: starting 1738
33
+ // CHECK-NEXT: finishing 679
34
+ await buttTest ( )
35
+
36
+ // CHECK-NEXT: getting dog
37
+ // CHECK-NEXT: dog number = 123
38
+ // CHECK-NEXT: obtaining cat has failed!
39
+ // CHECK-NEXT: caught exception
40
+ await farmTest ( )
41
+ }
42
+ }
43
+
44
+
You can’t perform that action at this time.
0 commit comments