@@ -1109,31 +1109,59 @@ actor MyServer : Server {
11091109// ----------------------------------------------------------------------
11101110// @_inheritActorContext
11111111// ----------------------------------------------------------------------
1112+ @available ( SwiftStdlib 5 . 1 , * )
11121113func acceptAsyncSendableClosure< T> ( _: @Sendable ( ) async -> T ) { }
1114+ @available ( SwiftStdlib 5 . 1 , * )
11131115func acceptAsyncSendableClosureInheriting< T> ( @_inheritActorContext _: @Sendable ( ) async -> T ) { }
11141116
11151117@available ( SwiftStdlib 5 . 1 , * )
11161118extension MyActor {
11171119 func testSendableAndInheriting( ) {
1120+ var counter = 0
1121+
11181122 acceptAsyncSendableClosure {
1119- synchronous ( ) // expected-error{{expression is 'async' but is not marked with 'await'}}
1123+ _ = synchronous ( ) // expected-error{{expression is 'async' but is not marked with 'await'}}
11201124 // expected-note@-1{{calls to instance method 'synchronous()' from outside of its actor context are implicitly asynchronous}}
1125+
1126+ counter += 1 // expected-error{{mutation of captured var 'counter' in concurrently-executing code}}
11211127 }
11221128
11231129 acceptAsyncSendableClosure {
1124- await synchronous ( ) // ok
1130+ _ = await synchronous ( ) // ok
1131+ counter += 1 // expected-error{{mutation of captured var 'counter' in concurrently-executing code}}
11251132 }
11261133
11271134 acceptAsyncSendableClosureInheriting {
1128- synchronous ( ) // okay
1135+ _ = synchronous ( ) // okay
1136+ counter += 1 // okay
11291137 }
11301138
11311139 acceptAsyncSendableClosureInheriting {
1132- await synchronous ( ) // expected-warning{{no 'async' operations occur within 'await' expression}}
1140+ _ = await synchronous ( ) // expected-warning{{no 'async' operations occur within 'await' expression}}
1141+ counter += 1 // okay
11331142 }
11341143 }
11351144}
11361145
1146+ @available ( SwiftStdlib 5 . 1 , * )
1147+ @SomeGlobalActor
1148+ func testGlobalActorInheritance( ) {
1149+ var counter = 0
1150+
1151+ acceptAsyncSendableClosure {
1152+ counter += 1 // expected-error{{mutation of captured var 'counter' in concurrently-executing code}}
1153+ }
1154+
1155+ acceptAsyncSendableClosure { @SomeGlobalActor in
1156+ counter += 1 // ok
1157+ }
1158+
1159+
1160+ acceptAsyncSendableClosureInheriting {
1161+ counter += 1 // ok
1162+ }
1163+ }
1164+
11371165@available ( SwiftStdlib 5 . 1 , * )
11381166@MainActor // expected-note {{'GloballyIsolatedProto' is isolated to global actor 'MainActor' here}}
11391167protocol GloballyIsolatedProto {
0 commit comments