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 {
3634
3634
return getExtInfo ().isNoEscape ();
3635
3635
}
3636
3636
3637
- bool isSendable () const {
3638
- return getExtInfo ().isSendable ();
3639
- }
3637
+ bool isSendable () const ;
3640
3638
3641
3639
bool isAsync () const { return getExtInfo ().isAsync (); }
3642
3640
Original file line number Diff line number Diff line change @@ -3895,6 +3895,15 @@ Type AnyFunctionType::getThrownError() const {
3895
3895
}
3896
3896
}
3897
3897
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
+
3898
3907
Type AnyFunctionType::getGlobalActor () const {
3899
3908
switch (getKind ()) {
3900
3909
case TypeKind::Function:
Original file line number Diff line number Diff line change @@ -559,7 +559,7 @@ extension MyActor {
559
559
560
560
func testBadImplicitGlobalActorClosureCall( ) async {
561
561
{ @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}}
563
563
}
564
564
565
565
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