@@ -979,31 +979,59 @@ actor MyServer : Server {
979
979
// ----------------------------------------------------------------------
980
980
// @_inheritActorContext
981
981
// ----------------------------------------------------------------------
982
+ @available ( SwiftStdlib 5 . 1 , * )
982
983
func acceptAsyncSendableClosure< T> ( _: @Sendable ( ) async -> T ) { }
984
+ @available ( SwiftStdlib 5 . 1 , * )
983
985
func acceptAsyncSendableClosureInheriting< T> ( @_inheritActorContext _: @Sendable ( ) async -> T ) { }
984
986
985
987
@available ( SwiftStdlib 5 . 1 , * )
986
988
extension MyActor {
987
989
func testSendableAndInheriting( ) {
990
+ var counter = 0
991
+
988
992
acceptAsyncSendableClosure {
989
- synchronous ( ) // expected-error{{expression is 'async' but is not marked with 'await'}}
993
+ _ = synchronous ( ) // expected-error{{expression is 'async' but is not marked with 'await'}}
990
994
// expected-note@-1{{calls to instance method 'synchronous()' from outside of its actor context are implicitly asynchronous}}
995
+
996
+ counter += 1 // expected-error{{mutation of captured var 'counter' in concurrently-executing code}}
991
997
}
992
998
993
999
acceptAsyncSendableClosure {
994
- await synchronous ( ) // ok
1000
+ _ = await synchronous ( ) // ok
1001
+ counter += 1 // expected-error{{mutation of captured var 'counter' in concurrently-executing code}}
995
1002
}
996
1003
997
1004
acceptAsyncSendableClosureInheriting {
998
- synchronous ( ) // okay
1005
+ _ = synchronous ( ) // okay
1006
+ counter += 1 // okay
999
1007
}
1000
1008
1001
1009
acceptAsyncSendableClosureInheriting {
1002
- await synchronous ( ) // expected-warning{{no 'async' operations occur within 'await' expression}}
1010
+ _ = await synchronous ( ) // expected-warning{{no 'async' operations occur within 'await' expression}}
1011
+ counter += 1 // okay
1003
1012
}
1004
1013
}
1005
1014
}
1006
1015
1016
+ @available ( SwiftStdlib 5 . 1 , * )
1017
+ @SomeGlobalActor
1018
+ func testGlobalActorInheritance( ) {
1019
+ var counter = 0
1020
+
1021
+ acceptAsyncSendableClosure {
1022
+ counter += 1 // expected-error{{mutation of captured var 'counter' in concurrently-executing code}}
1023
+ }
1024
+
1025
+ acceptAsyncSendableClosure { @SomeGlobalActor in
1026
+ counter += 1 // ok
1027
+ }
1028
+
1029
+
1030
+ acceptAsyncSendableClosureInheriting {
1031
+ counter += 1 // ok
1032
+ }
1033
+ }
1034
+
1007
1035
@available ( SwiftStdlib 5 . 1 , * )
1008
1036
@MainActor // expected-note {{'GloballyIsolatedProto' is isolated to global actor 'MainActor' here}}
1009
1037
protocol GloballyIsolatedProto {
0 commit comments