@@ -92,8 +92,10 @@ enum MyError: Error {
9292case fail
9393}
9494
95+ protocol P { }
96+
9597@_unsafeInheritExecutor
96- func unsafeCallerAvoidsNewLoop( clock : some Clock ) async throws {
98+ func unsafeCallerAvoidsNewLoop( ) async throws {
9799 // expected-warning@-1{{@_unsafeInheritExecutor attribute is deprecated; consider an 'isolated' parameter defaulted to '#isolation' instead}}
98100
99101 _ = await withUnsafeContinuation { ( continuation: UnsafeContinuation < Int , Never > ) in
@@ -129,13 +131,6 @@ func unsafeCallerAvoidsNewLoop(clock: some Clock) async throws {
129131 func operation( ) async throws -> Int { 7 }
130132 try await TL . $string. withValue ( " hello " , operation: operation)
131133
132- // FIXME: Clock.measure does not currently support this hack.
133- // expected-error@+1{{#isolation (introduced by a default argument) cannot be used within an '@_unsafeInheritExecutor' function}}
134- _ = try ! await clock. measure {
135- print ( " so very slow " )
136- try await Task . sleep ( nanoseconds: 500 )
137- }
138-
139134 _ = await withDiscardingTaskGroup ( returning: Int . self) { group in
140135 group. addTask {
141136 print ( " hello " )
@@ -173,6 +168,32 @@ func unsafeCallerAvoidsNewLoop(clock: some Clock) async throws {
173168 }
174169}
175170
171+ @_unsafeInheritExecutor
172+ func unsafeClockCaller(
173+ specificClock: ContinuousClock ,
174+ genericClock: some Clock ,
175+ existentialClock: any Clock ,
176+ existentialCompositionClock: any P & Clock ,
177+ ) async throws {
178+ // expected-warning@-6{{@_unsafeInheritExecutor attribute is deprecated; consider an 'isolated' parameter defaulted to '#isolation' instead}}
179+
180+ _ = try ! await specificClock. measure {
181+ try await Task . sleep ( nanoseconds: 500 )
182+ }
183+
184+ _ = try ! await genericClock. measure {
185+ try await Task . sleep ( nanoseconds: 500 )
186+ }
187+
188+ _ = try ! await existentialClock. measure {
189+ try await Task . sleep ( nanoseconds: 500 )
190+ }
191+
192+ _ = try ! await existentialCompositionClock. measure {
193+ try await Task . sleep ( nanoseconds: 500 )
194+ }
195+ }
196+
176197@_unsafeInheritExecutor
177198func _unsafeInheritExecutor_hacky( ) async { }
178199// expected-warning@-1{{@_unsafeInheritExecutor attribute is deprecated; consider an 'isolated' parameter defaulted to '#isolation' instead}}
0 commit comments