Skip to content

Commit 5f1d41b

Browse files
authored
Merge pull request #72298 from xedin/test-for-rdar122833729
[Tests] NFC: Test use of `@Sendable` attribute in result of ObjC methods
2 parents cbcfc85 + 1c19162 commit 5f1d41b

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// RUN: %empty-directory(%t/src)
2+
// RUN: %empty-directory(%t/sdk)
3+
// RUN: split-file %s %t/src
4+
5+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck %t/src/main.swift \
6+
// RUN: -import-objc-header %t/src/Test.h \
7+
// RUN: -swift-version 5 \
8+
// RUN: -disable-availability-checking \
9+
// RUN: -strict-concurrency=complete \
10+
// RUN: -module-name main -I %t -verify
11+
12+
// REQUIRES: objc_interop
13+
// REQUIRES: concurrency
14+
15+
//--- Test.h
16+
#define SWIFT_SENDABLE __attribute__((__swift_attr__("@Sendable")))
17+
18+
#pragma clang assume_nonnull begin
19+
20+
@import Foundation;
21+
22+
@interface Test: NSObject
23+
- (SWIFT_SENDABLE id)sendableReturnValue1;
24+
- (id SWIFT_SENDABLE)sendableReturnValue2;
25+
- (id)sendableReturnValue3 SWIFT_SENDABLE;
26+
@end
27+
28+
#pragma clang assume_nonnull end
29+
30+
//--- main.swift
31+
func test(test: Test) {
32+
let result1 = test.sendableReturnValue1()
33+
let result2 = test.sendableReturnValue2()
34+
let result3 = test.sendableReturnValue2()
35+
36+
Task.detached {
37+
_ = result1 // Ok
38+
_ = result2 // Ok
39+
_ = result3 // Ok
40+
}
41+
}

0 commit comments

Comments
 (0)