But the following code's result showed otherwise:
@MainActor
func test() async {
// job A
print("a")
Task { @MainActor in
// job B
print("b")
}
// job C
print("c")
}
await test()
try? await Task.sleep(for: .seconds(1))
// Output:
// a
// c
// b
Compiler explorer: Compiler Explorer
I think the actual behavior is consistent with what @ktoso said in another thread: Possibility of synchronous Task body execution - #10 by ktoso.