@@ -1007,65 +1007,81 @@ actor Butterfly {
10071007 }
10081008}
10091009
1010- // Test the isolation of `self` in constructors and deinits of an actor.
1011- // We know that Task.init accepts a special closure that inherits the isolation
1012- // of the context based on the isolation of values captured in the closure,
1013- // like `self`.
1010+ // expected-note@+1 2 {{calls to global function 'takeIsolated' from outside of its actor context are implicitly asynchronous}}
1011+ func takeIsolated ( _ val : isolated SelfParamIsolationNonMethod ) { }
1012+ func take ( _ val : SelfParamIsolationNonMethod ) { }
1013+
10141014actor SelfParamIsolationNonMethod {
10151015 init ( s0: Void ) {
1016- Task { self . f ( ) }
1016+ // expected-note@+2 {{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}
1017+ // expected-error@+1 {{expression is 'async' but is not marked with 'await'}}
1018+ acceptAsyncSendableClosureInheriting { self . f ( ) }
10171019
10181020 // expected-note@+2 {{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}
10191021 // expected-error@+1 {{expression is 'async' but is not marked with 'await'}}
1020- Task . detached { self . f ( ) }
1022+ acceptAsyncSendableClosure { self . f ( ) }
1023+
1024+ // expected-error@+1 {{call to actor-isolated global function 'takeIsolated' in a synchronous nonisolated context}}
1025+ takeIsolated ( self )
1026+
1027+ take ( self )
10211028 }
10221029
10231030 @MainActor init ( s1: Void ) {
10241031 // expected-note@+2 {{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}
10251032 // expected-error@+1 {{expression is 'async' but is not marked with 'await'}}
1026- Task { self . f ( ) }
1033+ acceptAsyncSendableClosureInheriting { self . f ( ) }
10271034
10281035 // expected-note@+2 {{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}
10291036 // expected-error@+1 {{expression is 'async' but is not marked with 'await'}}
1030- Task . detached { self . f ( ) }
1037+ acceptAsyncSendableClosure { self . f ( ) }
10311038 }
10321039
10331040 init ( a1: Void ) async {
1034- Task { self . f ( ) }
1041+ acceptAsyncSendableClosureInheriting { self . f ( ) }
10351042
10361043 // expected-note@+2 {{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}
10371044 // expected-error@+1 {{expression is 'async' but is not marked with 'await'}}
1038- Task . detached { self . f ( ) }
1045+ acceptAsyncSendableClosure { self . f ( ) }
1046+
1047+ takeIsolated ( self )
1048+
1049+ take ( self )
10391050 }
10401051
10411052 @MainActor init ( a2: Void ) async {
10421053 // expected-note@+2 {{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}
10431054 // expected-error@+1 {{expression is 'async' but is not marked with 'await'}}
1044- Task { self . f ( ) }
1055+ acceptAsyncSendableClosureInheriting { self . f ( ) }
10451056
10461057 // expected-note@+2 {{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}
10471058 // expected-error@+1 {{expression is 'async' but is not marked with 'await'}}
1048- Task . detached { self . f ( ) }
1059+ acceptAsyncSendableClosure { self . f ( ) }
10491060 }
10501061
10511062 nonisolated init ( a3: Void ) async {
10521063 // expected-note@+2 {{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}
10531064 // expected-error@+1 {{expression is 'async' but is not marked with 'await'}}
1054- Task { self . f ( ) }
1065+ acceptAsyncSendableClosureInheriting { self . f ( ) }
10551066
10561067 // expected-note@+2 {{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}
10571068 // expected-error@+1 {{expression is 'async' but is not marked with 'await'}}
1058- Task . detached { self . f ( ) }
1069+ acceptAsyncSendableClosure { self . f ( ) }
10591070 }
10601071
10611072 deinit {
10621073 // expected-note@+2 {{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}
10631074 // expected-error@+1 {{expression is 'async' but is not marked with 'await'}}
1064- Task { self . f ( ) }
1075+ acceptAsyncSendableClosureInheriting { self . f ( ) }
10651076
10661077 // expected-note@+2 {{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}
10671078 // expected-error@+1 {{expression is 'async' but is not marked with 'await'}}
1068- Task . detached { self . f ( ) }
1079+ acceptAsyncSendableClosure { self . f ( ) }
1080+
1081+ // expected-error@+1 {{call to actor-isolated global function 'takeIsolated' in a synchronous nonisolated context}}
1082+ takeIsolated ( self )
1083+
1084+ take ( self )
10691085 }
10701086
10711087 func f( ) { }
@@ -1074,21 +1090,21 @@ actor SelfParamIsolationNonMethod {
10741090@MainActor
10751091final class MainActorInit : Sendable {
10761092 init ( ) {
1077- Task { self . f ( ) }
1093+ acceptAsyncSendableClosureInheriting { self . f ( ) }
10781094
10791095 // expected-note@+2 {{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}
10801096 // expected-error@+1 {{expression is 'async' but is not marked with 'await'}}
1081- Task . detached { self . f ( ) }
1097+ acceptAsyncSendableClosure { self . f ( ) }
10821098 }
10831099
10841100 deinit {
10851101 // expected-note@+2 {{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}
10861102 // expected-error@+1 {{expression is 'async' but is not marked with 'await'}}
1087- Task { self . f ( ) }
1103+ acceptAsyncSendableClosureInheriting { self . f ( ) }
10881104
10891105 // expected-note@+2 {{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}
10901106 // expected-error@+1 {{expression is 'async' but is not marked with 'await'}}
1091- Task . detached { self . f ( ) }
1107+ acceptAsyncSendableClosure { self . f ( ) }
10921108 }
10931109
10941110 func f( ) { }
0 commit comments