@@ -92,8 +92,10 @@ enum MyError: Error {
92
92
case fail
93
93
}
94
94
95
+ protocol P { }
96
+
95
97
@_unsafeInheritExecutor
96
- func unsafeCallerAvoidsNewLoop( clock : some Clock ) async throws {
98
+ func unsafeCallerAvoidsNewLoop( ) async throws {
97
99
// expected-warning@-1{{@_unsafeInheritExecutor attribute is deprecated; consider an 'isolated' parameter defaulted to '#isolation' instead}}
98
100
99
101
_ = await withUnsafeContinuation { ( continuation: UnsafeContinuation < Int , Never > ) in
@@ -129,13 +131,6 @@ func unsafeCallerAvoidsNewLoop(clock: some Clock) async throws {
129
131
func operation( ) async throws -> Int { 7 }
130
132
try await TL . $string. withValue ( " hello " , operation: operation)
131
133
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
-
139
134
_ = await withDiscardingTaskGroup ( returning: Int . self) { group in
140
135
group. addTask {
141
136
print ( " hello " )
@@ -173,6 +168,32 @@ func unsafeCallerAvoidsNewLoop(clock: some Clock) async throws {
173
168
}
174
169
}
175
170
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
+
176
197
@_unsafeInheritExecutor
177
198
func _unsafeInheritExecutor_hacky( ) async { }
178
199
// expected-warning@-1{{@_unsafeInheritExecutor attribute is deprecated; consider an 'isolated' parameter defaulted to '#isolation' instead}}
0 commit comments