You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When calling a synthesized async function (i.e. synthesize from an Objective-C method) from a @mainactor function in Swift, execution resumes on a background thread instead of the main thread when the function throws an error.
Example: in the code the below, the assertion in the catch block fails.
@mainclassMainActorBug {
@MainActorstaticfuncmain() async {
letadder = Adder()
do {
letresult = tryawaitadder.add(-5)
assert(Thread.isMainThread)
print("The answer is \(result)")
} catch {
assert(Thread.isMainThread, "Not on main thread")
print(error)
}
}
}
Attachment: Download
Environment
Additional Detail from JIRA
md5: c52cb58ce3c02bb5270368dfb10304f1
Issue Description:
When calling a synthesized async function (i.e. synthesize from an Objective-C method) from a @mainactor function in Swift, execution resumes on a background thread instead of the main thread when the function throws an error.
Example: in the code the below, the assertion in the
catch
block fails.To reproduce:
The text was updated successfully, but these errors were encountered: