Avatar
@swift-main -Xfrontend -parse-as-library import Dispatch import Foundation func checkIfMainQueue(expectedAnswer expected: Bool) { dispatchPrecondition(condition: expected ? .onQueue(DispatchQueue.main) : .notOnQueue(DispatchQueue.main)) } @main struct Entrypoint { static func main() async throws { print("in main():", Thread.current, Thread.isMainThread) checkIfMainQueue(expectedAnswer: true) await MainActor.run { print("in MainActor.run:", Thread.current, Thread.isMainThread) checkIfMainQueue(expectedAnswer: true) } } } (edited)