Skip to content

Commit 3ae75e3

Browse files
authored
Merge pull request #59638 from DougGregor/drop-sendable-clang-type
2 parents 874172b + b32888d commit 3ae75e3

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

lib/AST/ClangTypeConverter.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,11 @@ clang::QualType ClangTypeConverter::visitProtocolType(ProtocolType *type) {
449449
auto proto = type->getDecl();
450450
auto &clangCtx = ClangASTContext;
451451

452+
// Strip 'Sendable'.
453+
auto strippedType = type->stripConcurrency(false, false);
454+
if (strippedType.getPointer() != type)
455+
return convert(strippedType);
456+
452457
if (!proto->isObjC())
453458
return clang::QualType();
454459

@@ -702,6 +707,11 @@ ClangTypeConverter::visitSILBlockStorageType(SILBlockStorageType *type) {
702707

703708
clang::QualType
704709
ClangTypeConverter::visitProtocolCompositionType(ProtocolCompositionType *type) {
710+
// Strip 'Sendable'.
711+
auto strippedType = type->stripConcurrency(false, false);
712+
if (strippedType.getPointer() != type)
713+
return convert(strippedType);
714+
705715
// Any will be lowered to AnyObject, so we return the same result.
706716
if (type->isAny())
707717
return getClangIdType(ClangASTContext);

lib/AST/Type.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,9 @@ ExistentialLayout::ExistentialLayout(CanProtocolCompositionType type) {
306306
protoDecl = parameterized->getProtocol();
307307
containsParameterized = true;
308308
}
309-
containsNonObjCProtocol |= !protoDecl->isObjC();
309+
containsNonObjCProtocol |=
310+
!protoDecl->isObjC() &&
311+
!protoDecl->isSpecificProtocol(KnownProtocolKind::Sendable);
310312
protocols.push_back(protoDecl);
311313
}
312314
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#import <Foundation/Foundation.h>
2+
3+
@interface A: NSObject
4+
- (id <NSObject>)foo __attribute__((swift_attr("@Sendable")));
5+
@end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %target-swift-frontend -emit-ir %s -swift-version 5 -import-objc-header %S/Inputs/objc_protocol_sendable.h | %IRGenFileCheck %s
2+
3+
// REQUIRES: objc_interop
4+
// REQUIRES: concurrency
5+
6+
// CHECK: define{{.*}}s22objc_protocol_sendable4test1aySo1AC_tF
7+
public func test(a: A) {
8+
a.foo()
9+
}

0 commit comments

Comments
 (0)