swiftwasm/JavaScriptKit

Compile error on macOS 12.2.1

valeriyvan opened this issue · 6 comments

/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JobQueue.swift:9:30: error: 'UnownedJob' is only available in macOS 10.15 or newer
    fileprivate var headJob: UnownedJob? = nil
                             ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JobQueue.swift:8:8: note: add @available attribute to enclosing struct
struct QueueState: Sendable {
       ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JobQueue.swift:15:37: error: 'UnownedJob' is only available in macOS 10.15 or newer
    func insertJobQueue(job newJob: UnownedJob) {
                                    ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JobQueue.swift:15:10: note: add @available attribute to enclosing instance method
    func insertJobQueue(job newJob: UnownedJob) {
         ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JobQueue.swift:13:1: note: add @available attribute to enclosing extension
extension JavaScriptEventLoop {
^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JobQueue.swift:49:34: error: 'UnownedJob' is only available in macOS 10.15 or newer
    func claimNextFromQueue() -> UnownedJob? {
                                 ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JobQueue.swift:49:10: note: add @available attribute to enclosing instance method
    func claimNextFromQueue() -> UnownedJob? {
         ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JobQueue.swift:13:1: note: add @available attribute to enclosing extension
extension JavaScriptEventLoop {
^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JobQueue.swift:69:48: error: 'UnownedJob' is only available in macOS 10.15 or newer
    func nextInQueue() -> UnsafeMutablePointer<UnownedJob?> {
                                               ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JobQueue.swift:69:10: note: add @available attribute to enclosing instance method
    func nextInQueue() -> UnsafeMutablePointer<UnownedJob?> {
         ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JobQueue.swift:58:13: note: add @available attribute to enclosing extension
fileprivate extension UnownedJob {
            ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JobQueue.swift:58:23: error: 'UnownedJob' is only available in macOS 10.15 or newer
fileprivate extension UnownedJob {
                      ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JobQueue.swift:58:13: note: add @available attribute to enclosing extension
fileprivate extension UnownedJob {
            ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JobQueue.swift:17:48: error: 'UnownedJob' is only available in macOS 10.15 or newer
            var position: UnsafeMutablePointer<UnownedJob?> = headJobPtr
                                               ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JobQueue.swift:17:48: note: add 'if #available' version check
            var position: UnsafeMutablePointer<UnownedJob?> = headJobPtr
                                               ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JobQueue.swift:15:10: note: add @available attribute to enclosing instance method
    func insertJobQueue(job newJob: UnownedJob) {
         ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JobQueue.swift:13:1: note: add @available attribute to enclosing extension
extension JavaScriptEventLoop {
^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JobQueue.swift:71:84: error: 'UnownedJob' is only available in macOS 10.15 or newer
            let nextJobPtr = UnsafeMutableRawPointer(rawNextJobPtr).bindMemory(to: UnownedJob?.self, capacity: 1)
                                                                                   ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JobQueue.swift:71:84: note: add 'if #available' version check
            let nextJobPtr = UnsafeMutableRawPointer(rawNextJobPtr).bindMemory(to: UnownedJob?.self, capacity: 1)
                                                                                   ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JobQueue.swift:69:10: note: add @available attribute to enclosing instance method
    func nextInQueue() -> UnsafeMutablePointer<UnownedJob?> {
         ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JobQueue.swift:58:13: note: add @available attribute to enclosing extension
fileprivate extension UnownedJob {
            ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:81:33: error: 'UnownedJob' is only available in macOS 10.15 or newer
    private func enqueue(_ job: UnownedJob, withDelay nanoseconds: UInt64) {
                                ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:81:18: note: add @available attribute to enclosing instance method
    private func enqueue(_ job: UnownedJob, withDelay nanoseconds: UInt64) {
                 ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:6:20: note: add @available attribute to enclosing class
public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {
                   ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:88:32: error: 'UnownedJob' is only available in macOS 10.15 or newer
    public func enqueue(_ job: UnownedJob) {
                               ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:88:17: note: add @available attribute to enclosing instance method
    public func enqueue(_ job: UnownedJob) {
                ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:6:20: note: add @available attribute to enclosing class
public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {
                   ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:92:46: error: 'UnownedSerialExecutor' is only available in macOS 10.15 or newer
    public func asUnownedSerialExecutor() -> UnownedSerialExecutor {
                                             ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:92:17: note: add @available attribute to enclosing instance method
    public func asUnownedSerialExecutor() -> UnownedSerialExecutor {
                ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:6:20: note: add @available attribute to enclosing class
public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {
                   ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:60:73: error: 'UnownedJob' is only available in macOS 10.15 or newer
        typealias swift_task_enqueueGlobal_hook_Fn = @convention(thin) (UnownedJob, swift_task_enqueueGlobal_original) -> Void
                                                                        ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:57:24: note: add @available attribute to enclosing static method
    public static func installGlobalExecutor() {
                       ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:6:20: note: add @available attribute to enclosing class
public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {
                   ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:66:90: error: 'UnownedJob' is only available in macOS 10.15 or newer
        typealias swift_task_enqueueGlobalWithDelay_hook_Fn = @convention(thin) (UInt64, UnownedJob, swift_task_enqueueGlobalWithDelay_original) -> Void
                                                                                         ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:57:24: note: add @available attribute to enclosing static method
    public static func installGlobalExecutor() {
                       ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:6:20: note: add @available attribute to enclosing class
public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {
                   ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:72:79: error: 'UnownedJob' is only available in macOS 10.15 or newer
        typealias swift_task_enqueueMainExecutor_hook_Fn = @convention(thin) (UnownedJob, swift_task_enqueueMainExecutor_original) -> Void
                                                                              ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:57:24: note: add @available attribute to enclosing static method
    public static func installGlobalExecutor() {
                       ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:6:20: note: add @available attribute to enclosing class
public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {
                   ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:93:16: error: 'UnownedSerialExecutor' is only available in macOS 10.15 or newer
        return UnownedSerialExecutor(ordinary: self)
               ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:93:16: note: add 'if #available' version check
        return UnownedSerialExecutor(ordinary: self)
               ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:92:17: note: add @available attribute to enclosing instance method
    public func asUnownedSerialExecutor() -> UnownedSerialExecutor {
                ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:6:20: note: add @available attribute to enclosing class
public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {
                   ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:101:23: error: 'withUnsafeThrowingContinuation' is only available in macOS 10.15 or newer
            try await withUnsafeThrowingContinuation { [self] continuation in
                      ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:101:23: note: add 'if #available' version check
            try await withUnsafeThrowingContinuation { [self] continuation in
                      ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:99:9: note: add @available attribute to enclosing property
    var value: JSValue {
        ^
/Users/xxxxxxxxxx/Documents/JavaScriptKit/Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift:97:8: note: add @available attribute to enclosing extension
public extension JSPromise {
       ^

First of all, this package won't support macOS, and I don't think this error could happen in application development targeting wasm.

I wonder if we should provide some stubs on macOS to at least make code completion work if someone imports JavaScriptEventLoop module?

Finding a solution would be greatly appreciated. I edit my code on Xcode so I find it really hard to have to comment out the dependency to get actual diagnostics and then uncomment to run with carton.

Maybe we could add .platforms(.macos(.v10_15)) to the Package.swift or we could add @available(macOS 10.15, *) to the classes in JavaScriptEventLoop. I have done this for my local copy, because the documentation would not build otherwise.

I can work on this if we decide on which of the approaches to go for?

Edit: I see a pull request has already been opened

I couldn't figure out a feasible solution to improve development experience with Xcode, so adding availability guards is reasonable to me now. Sorry for taking a long time.

No worries; glad it’s fixed now.