 
       repeat {
         waiter.pointee.next = state.waiters?.assumingMemoryBound(to: Waiter<Value>.self)
-        let newState = Int(bitPattern: waiter) | (state & .resolving)
+        let newState = Int(bitPattern: waiter) | state.state
         if CAtomicsCompareAndExchange(deferredState, &state, newState, .weak, .release, .relaxed)
         { // waiter is now enqueued; it will be deallocated at a later time by notifyWaiters()
           return

  @discardableResult
  fileprivate func resolve(_ result: Result<Value, Error>) -> Bool
  {
    let originalState = CAtomicsLoad(deferredState, .relaxed).state
    guard originalState != .resolving else { return false }

    let updatedState = CAtomicsBitwiseOr(deferredState, .resolving, .acqrel).state
    guard updatedState != .resolving else { return false }
    // this thread has exclusive access

    resolved = result

    // This atomic swap operation uses memory order .acqrel.
    // "release" ordering ensures visibility of changes to `resolved` above to another thread.
    // "acquire" ordering ensures visibility of changes to `waitQueue` from another thread.
    // Any atomic load of `waiters` that precedes a possible use of `resolved`
    // *must* use memory order .acquire.
    let state = CAtomicsExchange(deferredState, .resolved, .acqrel)
    // precondition(state.isResolved == false)
    let waitQueue = state.waiters?.assumingMemoryBound(to: Waiter<Value>.self)
    notifyWaiters(queue, waitQueue, result)

    // precondition(deferredState.load(.relaxed) == .resolved,
    //              "deferredState has incorrect value \(String(deferredState.load(.relaxed), radix: 16))")

    // This `Deferred` has been resolved
    return true


      repeat {
        waiter.pointee.next = state.waiters?.assumingMemoryBound(to: Waiter<Value>.self)
        let newState = Int(bitPattern: waiter) | state.state
        if CAtomicsCompareAndExchange(deferredState, &state, newState, .weak, .release, .relaxed)
        { // waiter is now enqueued; it will be deallocated at a later time by notifyWaiters()
          return
