Skip to content

Commit 5286d9c

Browse files
authored
Merge pull request swiftlang#34804 from DougGregor/concurrency-import-mirrored-protocols
[Clang importer] Make sure we mirror protocol decls for all names.
2 parents 4a9ab66 + c7c0fed commit 5286d9c

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7463,9 +7463,20 @@ void SwiftDeclConverter::importNonOverriddenMirroredMethods(DeclContext *dc,
74637463
Impl.importMirroredDecl(objcMethod, dc, getVersion(), proto)) {
74647464
members.push_back(imported);
74657465

7466-
for (auto alternate : Impl.getAlternateDecls(imported))
7466+
for (auto alternate : Impl.getAlternateDecls(imported)) {
74677467
if (imported->getDeclContext() == alternate->getDeclContext())
74687468
members.push_back(alternate);
7469+
}
7470+
7471+
if (Impl.SwiftContext.LangOpts.EnableExperimentalConcurrency &&
7472+
!getVersion().supportsConcurrency()) {
7473+
auto asyncVersion = getVersion().withConcurrency(true);
7474+
if (auto asyncImport = Impl.importMirroredDecl(
7475+
objcMethod, dc, asyncVersion, proto)) {
7476+
if (asyncImport != imported)
7477+
members.push_back(asyncImport);
7478+
}
7479+
}
74697480
}
74707481
}
74717482
}

test/ClangImporter/objc_async.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ func testSlowServer(slowServer: SlowServer) async throws {
2525

2626
await slowServer.serverRestart("localhost")
2727
await slowServer.server("localhost", atPriorityRestart: 0.8)
28+
29+
_ = await slowServer.allOperations()
2830
}
2931

3032
func testSlowServerSynchronous(slowServer: SlowServer) {
@@ -36,4 +38,6 @@ func testSlowServerOldSchool(slowServer: SlowServer) {
3638
slowServer.doSomethingSlow("mail") { i in
3739
_ = i
3840
}
41+
42+
_ = slowServer.allOperations
3943
}

test/IDE/print_clang_objc_async.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// REQUIRES: objc_interop
77
// REQUIRES: concurrency
88

9-
// CHECK-LABEL: class SlowServer : NSObject {
9+
// CHECK-LABEL: class SlowServer : NSObject, ServiceProvider {
1010
// CHECK-DAG: func doSomethingSlow(_ operation: String, completionHandler handler: @escaping (Int) -> Void)
1111
// CHECK-DAG: func doSomethingSlow(_ operation: String) async -> Int
1212
// CHECK-DAG: func doSomethingDangerous(_ operation: String, completionHandler handler: ((String?, Error?) -> Void)? = nil)

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33

44
#pragma clang assume_nonnull begin
55

6-
@interface SlowServer : NSObject
6+
@protocol ServiceProvider
7+
@property(readonly) NSArray<NSString *> *allOperations;
8+
-(void)allOperationsWithCompletionHandler:(void (^)(NSArray<NSString *> *))completion;
9+
@end
10+
11+
@interface SlowServer : NSObject <ServiceProvider>
712
-(void)doSomethingSlow:(NSString *)operation completionHandler:(void (^)(NSInteger))handler;
813
-(void)doSomethingDangerous:(NSString *)operation completionHandler:(void (^ _Nullable)(NSString *_Nullable, NSError * _Nullable))handler;
914
-(void)checkAvailabilityWithCompletionHandler:(void (^)(BOOL isAvailable))completionHandler;

0 commit comments

Comments
 (0)