Skip to content

Commit 2f62342

Browse files
authored
Merge pull request #83107 from jckarter/semantic-store-preconcurrency
SILGen: Have emitSemanticStore cast off concurrency annotations.
2 parents a2b11cf + 0e94c63 commit 2f62342

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

lib/SILGen/SILGenLValue.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5227,6 +5227,14 @@ void SILGenFunction::emitSemanticStore(SILLocation loc,
52275227
dest = B.createMoveOnlyWrapperToCopyableAddr(loc, dest);
52285228
}
52295229

5230+
// If the dest type differs only in concurrency annotations, we can cast them
5231+
// off.
5232+
if (dest->getType().getObjectType() != rvalue->getType().getObjectType()
5233+
&& dest->getType().stripConcurrency(/*recursive*/true, /*dropGlobal*/true)
5234+
== rvalue->getType().stripConcurrency(true, true)) {
5235+
dest = B.createUncheckedAddrCast(loc, dest, rvalue->getType().getAddressType());
5236+
}
5237+
52305238
// Easy case: the types match.
52315239
if (rvalue->getType().getObjectType() == dest->getType().getObjectType()) {
52325240
assert(!silConv.useLoweredAddresses() ||
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@import Foundation;
2+
3+
#define NS_SWIFT_SENDABLE __attribute__((__swift_attr__("@Sendable")))
4+
5+
@interface TestClass: NSObject
6+
7+
- (_Nullable id NS_SWIFT_SENDABLE)foo;
8+
9+
@end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %target-swift-emit-silgen(mock-sdk: %clang-importer-sdk) -import-objc-header %S/Inputs/preconcurrency-bridged-return.h -swift-version 5 %s
2+
//
3+
// REQUIRES: objc_interop
4+
5+
func test(x: TestClass) {
6+
let foo = x.foo()
7+
}
8+

0 commit comments

Comments
 (0)