File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -319,3 +319,32 @@ func isolatedClosures() {
319
319
a. f ( )
320
320
}
321
321
}
322
+
323
+ // Test case for https://github.com/apple/swift/issues/62568
324
+ func execute< ActorType: Actor > (
325
+ on isolatedActor: isolated ActorType,
326
+ task: @escaping @Sendable ( isolated ActorType) -> Void)
327
+ {
328
+ // Compiler correctly allows this task to execute synchronously.
329
+ task ( isolatedActor)
330
+ // Start a task that inherits the current execution context (i.e. that of the isolatedActor)
331
+ Task {
332
+ // 'await' is not not necessary because 'task' is synchronous.
333
+ task ( isolatedActor)
334
+ }
335
+ }
336
+
337
+ actor ProtectsDictionary {
338
+ var dictionary : [ String : String ] = [ " A " : " B " ]
339
+ }
340
+
341
+ func getValues(
342
+ forKeys keys: [ String] ,
343
+ from actor : isolated ProtectsDictionary
344
+ ) - > [ String? ] {
345
+ // A non-escaping, synchronous closure cannot cross isolation
346
+ // boundaries; it should be isolated to 'actor'.
347
+ keys. map { key in
348
+ actor . dictionary [ key]
349
+ }
350
+ }
You can’t perform that action at this time.
0 commit comments