File tree Expand file tree Collapse file tree 3 files changed +39
-4
lines changed Expand file tree Collapse file tree 3 files changed +39
-4
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,10 @@ struct ExistentialLayout {
105
105
// / Zero or more primary associated type requirements from a
106
106
// / ParameterizedProtocolType
107
107
ArrayRef<Type> sameTypeRequirements;
108
+
109
+ // / Existentials allow a relaxed notion of \c ValueDecl::isObjC
110
+ // / that includes `Sendable` protocol.
111
+ static bool isObjCProtocol (ProtocolDecl *P);
108
112
};
109
113
110
114
}
Original file line number Diff line number Diff line change @@ -299,7 +299,7 @@ ExistentialLayout::ExistentialLayout(CanProtocolType type) {
299
299
auto *protoDecl = type->getDecl ();
300
300
301
301
hasExplicitAnyObject = false ;
302
- containsNonObjCProtocol = !protoDecl-> isObjC ( );
302
+ containsNonObjCProtocol = !isObjCProtocol (protoDecl );
303
303
containsParameterized = false ;
304
304
305
305
protocols.push_back (protoDecl);
@@ -327,9 +327,7 @@ ExistentialLayout::ExistentialLayout(CanProtocolCompositionType type) {
327
327
protoDecl = parameterized->getProtocol ();
328
328
containsParameterized = true ;
329
329
}
330
- containsNonObjCProtocol |=
331
- !protoDecl->isObjC () &&
332
- !protoDecl->isSpecificProtocol (KnownProtocolKind::Sendable);
330
+ containsNonObjCProtocol |= !isObjCProtocol (protoDecl);
333
331
protocols.push_back (protoDecl);
334
332
}
335
333
}
@@ -340,6 +338,10 @@ ExistentialLayout::ExistentialLayout(CanParameterizedProtocolType type)
340
338
containsParameterized = true ;
341
339
}
342
340
341
+ bool ExistentialLayout::isObjCProtocol (ProtocolDecl *P) {
342
+ return P->isObjC () || P->isSpecificProtocol (KnownProtocolKind::Sendable);
343
+ }
344
+
343
345
ExistentialLayout TypeBase::getExistentialLayout () {
344
346
return getCanonicalType ().getExistentialLayout ();
345
347
}
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck %s -parse-as-library -emit-objc-header-path %t/swift.h
3
+ // RUN: %FileCheck %s < %t/swift.h
4
+
5
+ // REQUIRES: concurrency
6
+ // REQUIRES: asserts
7
+ // REQUIRES: objc_interop
8
+
9
+ import Foundation
10
+
11
+ @objc public protocol P { }
12
+
13
+ @objc public class Klass : NSObject {
14
+ // CHECK: - (void)test1:(NSDictionary<NSString *, id> * _Nonnull)_;
15
+ @objc public func test1( _: [ String : any Sendable ] ) { }
16
+ // CHECK: - (void)test2:(NSDictionary<NSString *, id <P>> * _Nonnull)_;
17
+ @objc public func test2( _: [ String : any P & Sendable ] ) { }
18
+ }
19
+
20
+ @objc public protocol Q {
21
+ // CHECK: - (NSArray<NSDictionary<NSString *, id> *> * _Nonnull)data1 SWIFT_WARN_UNUSED_RESULT;
22
+ func data1( ) -> [ [ String : any Sendable ] ]
23
+ // CHECK: - (NSArray<id> * _Nullable)data2 SWIFT_WARN_UNUSED_RESULT;
24
+ func data2( ) -> [ any Sendable ] ?
25
+ // CHECK: - (void)data3:(id _Nonnull)_;
26
+ func data3( _: any Sendable )
27
+ // CHECK: - (void)data4:(id _Nullable)_;
28
+ func data4( _: ( any Sendable ) ? )
29
+ }
You can’t perform that action at this time.
0 commit comments