File tree Expand file tree Collapse file tree 4 files changed +26
-0
lines changed
Inputs/clang-importer-sdk/usr/include Expand file tree Collapse file tree 4 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -1739,6 +1739,15 @@ Type ClangImporter::Implementation::applyParamAttributes(
1739
1739
1740
1740
continue ;
1741
1741
}
1742
+
1743
+ // Map @Sendable.
1744
+ if (swiftAttr->getAttribute () == " @Sendable" ) {
1745
+ type = applyToFunctionType (type, [](ASTExtInfo extInfo) {
1746
+ return extInfo.withConcurrent ();
1747
+ });
1748
+
1749
+ continue ;
1750
+ }
1742
1751
}
1743
1752
1744
1753
return type;
Original file line number Diff line number Diff line change @@ -82,6 +82,18 @@ func testSlowServerOldSchool(slowServer: SlowServer) {
82
82
_ = slowServer. allOperations
83
83
}
84
84
85
+ func testSendable( fn: ( ) -> Void ) { // expected-note{{parameter 'fn' is implicitly non-concurrent}}
86
+ doSomethingConcurrently ( fn)
87
+ // expected-error@-1{{passing non-concurrent parameter 'fn' to function expecting a @Sendable closure}}
88
+
89
+ var x = 17
90
+ doSomethingConcurrently {
91
+ print ( x) // expected-error{{reference to captured var 'x' in concurrently-executing code}}
92
+ x = x + 1 // expected-error{{mutation of captured var 'x' in concurrently-executing code}}
93
+ // expected-error@-1{{reference to captured var 'x' in concurrently-executing code}}
94
+ }
95
+ }
96
+
85
97
// Check import of attributes
86
98
func globalAsync( ) async { }
87
99
Original file line number Diff line number Diff line change @@ -47,3 +47,5 @@ import _Concurrency
47
47
// CHECK-NEXT: {{^[}]$}}
48
48
49
49
// CHECK: {{^}}var MAGIC_NUMBER: Int32 { get }
50
+
51
+ // CHECK: func doSomethingConcurrently(_ block: @Sendable () -> Void)
Original file line number Diff line number Diff line change @@ -144,4 +144,7 @@ __attribute__((__swift_attr__("@MainActor(unsafe)")))
144
144
-(void )onButtonPress ;
145
145
@end
146
146
147
+ // Do something concurrently, but without escaping.
148
+ void doSomethingConcurrently (__attribute__((noescape)) __attribute__((swift_attr(" @Sendable" ))) void (^block)(void ));
149
+
147
150
#pragma clang assume_nonnull end
You can’t perform that action at this time.
0 commit comments