File tree Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -1153,8 +1153,19 @@ namespace {
1153
1153
Protocols.push_back (proto);
1154
1154
}
1155
1155
1156
- for (Decl *member : theProtocol->getMembers ())
1156
+ for (Decl *member : theProtocol->getMembers ()) {
1157
+ // Async methods coming from ObjC protocols shouldn't be recorded twice.
1158
+ // At the moment, the language doesn't allow suppressing the
1159
+ // completionHandler-based variant, so this is sufficient.
1160
+ if (theProtocol->hasClangNode () && theProtocol->isObjC ()) {
1161
+ if (auto funcOrAccessor = dyn_cast<AbstractFunctionDecl>(member)) {
1162
+ if (funcOrAccessor->isAsyncContext ()) {
1163
+ continue ;
1164
+ }
1165
+ }
1166
+ }
1157
1167
visit (member);
1168
+ }
1158
1169
}
1159
1170
1160
1171
// / Gather protocol records for all of the explicitly-specified Objective-C
Original file line number Diff line number Diff line change 17
17
18
18
@end
19
19
20
+ @protocol MyAsyncProtocol
21
+ -(void )myAsyncMethod : (void (^ _Nullable)(NSError * _Nullable, NSString * _Nullable))completionHandler ;
22
+ @end
20
23
21
24
#endif
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-experimental-concurrency -import-objc-header %S/Inputs/Delegate.h %s -emit-ir -o - | %FileCheck %s
2
+ // REQUIRES: concurrency
3
+ // REQUIRES: objc_interop
4
+
5
+
6
+ let anyObject : AnyObject = ( MyAsyncProtocol . self as AnyObject ) // or something like this
7
+
8
+ // rdar://76192003
9
+ // Make sure we don't emit 2 copies of methods, due to a completion-handler
10
+ // version and another due to an async based version.
11
+
12
+ // CHECK-LABEL: @_PROTOCOL_INSTANCE_METHODS_MyAsyncProtocol = internal constant
13
+ // CHECK-SAME: selector_data(myAsyncMethod:)
14
+ // CHECK-NOT: selector_data(myAsyncMethod:)
15
+ // CHECK-SAME: align 8
You can’t perform that action at this time.
0 commit comments