Skip to content

Commit ae3049f

Browse files
committed
[Importer] Make sure we drop "WithBlock" as a completion-handler suffix.
Fixes rdar://73641827.
1 parent e2893cf commit ae3049f

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

lib/Basic/StringExtras.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,10 @@ Optional<StringRef> swift::stripWithCompletionHandlerSuffix(StringRef name) {
13741374
return name.drop_back(strlen("WithCompletionBlock"));
13751375
}
13761376

1377+
if (name.endswith("WithBlock")) {
1378+
return name.drop_back(strlen("WithBlock"));
1379+
}
1380+
13771381
if (name.endswith("WithReplyTo")) {
13781382
return name.drop_back(strlen("WithReplyTo"));
13791383
}

test/ClangImporter/objc_async.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func testSlowServer(slowServer: SlowServer) async throws {
4646
slowServer.repeatTrick("jump") // expected-error{{missing argument for parameter 'completionHandler' in call}}
4747

4848
_ = try await slowServer.oldAPI(); // expected-error{{'oldAPI()' is unavailable in macOS: APIs deprecated as of macOS 10.14 and earlier are not imported as 'async'}}
49+
_ = try await slowServer.someAsyncMethod()
4950
}
5051

5152
func testSlowServerSynchronous(slowServer: SlowServer) {

test/Inputs/clang-importer-sdk/usr/include/ObjCConcurrency.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ typedef void (^CompletionHandler)(NSString * _Nullable, NSString * _Nullable_res
5555
- (void)getSomeObjectWithCompletionHandler:(nullable void (^)(NSObject *_Nullable x, NSError *_Nullable error))handler;
5656

5757
-(void)oldAPIWithCompletionHandler:(void (^ _Nonnull)(NSString *_Nullable, NSError *_Nullable))handler __attribute__((availability(macosx, deprecated=10.14)));
58+
59+
-(void)someAsyncMethodWithBlock:(void (^ _Nonnull)(NSString *_Nullable, NSError *_Nullable))completionHandler;
5860
@end
5961

6062
@protocol RefrigeratorDelegate<NSObject>

0 commit comments

Comments
 (0)