Skip to content

Commit 68a4b31

Browse files
committed
[NFC][Concurrency] Add a test case for inheriting actor context within a
function that uses isolated parameters.
1 parent 3ae1c3f commit 68a4b31

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/Concurrency/isolated_parameters.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,3 +319,17 @@ func isolatedClosures() {
319319
a.f()
320320
}
321321
}
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+
}

0 commit comments

Comments
 (0)