Skip to content

Commit 32cd086

Browse files
authored
Merge pull request #72259 from tshortli/typed-throws-without-actually-escaping
Concurrency: Guard use of `withoutActuallyEscaping()` in inlinable code
2 parents aac2051 + 65c0ef8 commit 32cd086

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

stdlib/public/Concurrency/ExecutorAssertions.swift

+4
Original file line numberDiff line numberDiff line change
@@ -363,12 +363,16 @@ extension Actor {
363363
fatalError("Incorrect actor executor assumption; Expected same executor as \(self).", file: file, line: line)
364364
}
365365

366+
#if $TypedThrows
366367
// To do the unsafe cast, we have to pretend it's @escaping.
367368
return try withoutActuallyEscaping(operation) {
368369
(_ fn: @escaping YesActor) throws -> T in
369370
let rawFn = unsafeBitCast(fn, to: NoActor.self)
370371
return try rawFn(self)
371372
}
373+
#else
374+
fatalError("unsupported compiler")
375+
#endif
372376
}
373377
}
374378

stdlib/public/Concurrency/MainActor.swift

+4
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,16 @@ extension MainActor {
155155
fatalError("Incorrect actor executor assumption; Expected same executor as \(self).", file: file, line: line)
156156
}
157157

158+
#if $TypedThrows
158159
// To do the unsafe cast, we have to pretend it's @escaping.
159160
return try withoutActuallyEscaping(operation) {
160161
(_ fn: @escaping YesActor) throws -> T in
161162
let rawFn = unsafeBitCast(fn, to: NoActor.self)
162163
return try rawFn()
163164
}
165+
#else
166+
fatalError("unsupported compiler")
167+
#endif
164168
}
165169
}
166170
#endif

stdlib/public/Distributed/DistributedAssertions.swift

+4
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,16 @@ extension DistributedActor {
174174
fatalError("Incorrect actor executor assumption; Expected same executor as \(self).", file: file, line: line)
175175
}
176176

177+
#if $TypedThrows
177178
// To do the unsafe cast, we have to pretend it's @escaping.
178179
return try withoutActuallyEscaping(operation) {
179180
(_ fn: @escaping YesActor) throws -> T in
180181
let rawFn = unsafeBitCast(fn, to: NoActor.self)
181182
return try rawFn(self)
182183
}
184+
#else
185+
fatalError("unsupported compiler")
186+
#endif
183187
}
184188
}
185189

0 commit comments

Comments
 (0)