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(
17391739
17401740 continue ;
17411741 }
1742+
1743+ // Map @Sendable.
1744+ if (swiftAttr->getAttribute () == " @Sendable" ) {
1745+ type = applyToFunctionType (type, [](ASTExtInfo extInfo) {
1746+ return extInfo.withConcurrent ();
1747+ });
1748+
1749+ continue ;
1750+ }
17421751 }
17431752
17441753 return type;
Original file line number Diff line number Diff line change @@ -82,6 +82,18 @@ func testSlowServerOldSchool(slowServer: SlowServer) {
8282 _ = slowServer. allOperations
8383}
8484
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+
8597// Check import of attributes
8698func globalAsync( ) async { }
8799
Original file line number Diff line number Diff line change @@ -47,3 +47,5 @@ import _Concurrency
4747// CHECK-NEXT: {{^[}]$}}
4848
4949// 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)")))
144144-(void )onButtonPress ;
145145@end
146146
147+ // Do something concurrently, but without escaping.
148+ void doSomethingConcurrently (__attribute__((noescape)) __attribute__((swift_attr(" @Sendable" ))) void (^block)(void ));
149+
147150#pragma clang assume_nonnull end
You can’t perform that action at this time.
0 commit comments