Skip to content

Concurrency: Guard use of withoutActuallyEscaping() in inlinable code #72259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions stdlib/public/Concurrency/ExecutorAssertions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,16 @@ extension Actor {
fatalError("Incorrect actor executor assumption; Expected same executor as \(self).", file: file, line: line)
}

#if $TypedThrows
// To do the unsafe cast, we have to pretend it's @escaping.
return try withoutActuallyEscaping(operation) {
(_ fn: @escaping YesActor) throws -> T in
let rawFn = unsafeBitCast(fn, to: NoActor.self)
return try rawFn(self)
}
#else
fatalError("unsupported compiler")
#endif
}
}

Expand Down
4 changes: 4 additions & 0 deletions stdlib/public/Concurrency/MainActor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,16 @@ extension MainActor {
fatalError("Incorrect actor executor assumption; Expected same executor as \(self).", file: file, line: line)
}

#if $TypedThrows
// To do the unsafe cast, we have to pretend it's @escaping.
return try withoutActuallyEscaping(operation) {
(_ fn: @escaping YesActor) throws -> T in
let rawFn = unsafeBitCast(fn, to: NoActor.self)
return try rawFn()
}
#else
fatalError("unsupported compiler")
#endif
}
}
#endif
4 changes: 4 additions & 0 deletions stdlib/public/Distributed/DistributedAssertions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,16 @@ extension DistributedActor {
fatalError("Incorrect actor executor assumption; Expected same executor as \(self).", file: file, line: line)
}

#if $TypedThrows
// To do the unsafe cast, we have to pretend it's @escaping.
return try withoutActuallyEscaping(operation) {
(_ fn: @escaping YesActor) throws -> T in
let rawFn = unsafeBitCast(fn, to: NoActor.self)
return try rawFn(self)
}
#else
fatalError("unsupported compiler")
#endif
}
}

Expand Down