Skip to content

Commit dfa7b86

Browse files
committed
[Concurrency] Clock.measure should inherit actor isolation.
1 parent 377b527 commit dfa7b86

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

stdlib/public/Concurrency/Clock.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,18 @@ extension Clock {
6767
/// await someWork()
6868
/// }
6969
@available(SwiftStdlib 5.7, *)
70+
@_alwaysEmitIntoClient
7071
public func measure(
72+
isolation: isolated (any Actor)? = #isolation,
73+
_ work: () async throws -> Void
74+
) async rethrows -> Instant.Duration {
75+
try await measure(work)
76+
}
77+
78+
@available(SwiftStdlib 5.7, *)
79+
@_unsafeInheritExecutor
80+
@usableFromInline
81+
internal func measure(
7182
_ work: () async throws -> Void
7283
) async rethrows -> Instant.Duration {
7384
let start = now

test/Concurrency/Runtime/clock.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// RUN: %target-typecheck-verify-swift -strict-concurrency=complete -disable-availability-checking -parse-as-library
12
// RUN: %target-run-simple-swift( -Xfrontend -disable-availability-checking -parse-as-library)
23

34
// REQUIRES: concurrency
@@ -12,7 +13,7 @@
1213
import _Concurrency
1314
import StdlibUnittest
1415

15-
var tests = TestSuite("Time")
16+
@MainActor var tests = TestSuite("Time")
1617

1718
@main struct Main {
1819
static func main() async {

0 commit comments

Comments
 (0)