File tree Expand file tree Collapse file tree 4 files changed +23
-4
lines changed Expand file tree Collapse file tree 4 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -3634,9 +3634,7 @@ class AnyFunctionType : public TypeBase {
36343634 return getExtInfo ().isNoEscape ();
36353635 }
36363636
3637- bool isSendable () const {
3638- return getExtInfo ().isSendable ();
3639- }
3637+ bool isSendable () const ;
36403638
36413639 bool isAsync () const { return getExtInfo ().isAsync (); }
36423640
Original file line number Diff line number Diff line change @@ -3895,6 +3895,15 @@ Type AnyFunctionType::getThrownError() const {
38953895 }
38963896}
38973897
3898+ bool AnyFunctionType::isSendable () const {
3899+ auto &ctx = getASTContext ();
3900+ if (ctx.LangOpts .hasFeature (Feature::GlobalActorIsolatedTypesUsability)) {
3901+ // Global-actor-isolated function types are implicitly Sendable.
3902+ return getExtInfo ().isSendable () || getIsolation ().isGlobalActor ();
3903+ }
3904+ return getExtInfo ().isSendable ();
3905+ }
3906+
38983907Type AnyFunctionType::getGlobalActor () const {
38993908 switch (getKind ()) {
39003909 case TypeKind::Function:
Original file line number Diff line number Diff line change @@ -559,7 +559,7 @@ extension MyActor {
559559
560560func testBadImplicitGlobalActorClosureCall( ) async {
561561 { @MainActor in } ( ) // expected-error{{expression is 'async' but is not marked with 'await'}}
562- // expected-note@-1{{calls function of type '@MainActor () -> ()' from outside of its actor context are implicitly asynchronous}}
562+ // expected-note@-1{{calls function of type '@MainActor @Sendable () -> ()' from outside of its actor context are implicitly asynchronous}}
563563}
564564
565565
Original file line number Diff line number Diff line change 1+ // RUN: %target-typecheck-verify-swift -strict-concurrency=complete -disable-availability-checking -enable-upcoming-feature RegionBasedIsolation -enable-experimental-feature GlobalActorIsolatedTypesUsability
2+
3+ // REQUIRES: concurrency
4+ // REQUIRES: asserts
5+
6+ func inferSendableFunctionType( ) {
7+ let closure : @MainActor ( ) -> Void = { }
8+
9+ Task {
10+ await closure ( ) // okay
11+ }
12+ }
You can’t perform that action at this time.
0 commit comments