# \`Task.yield()\` never resumes when having a borrowing access to a non-copyable member of a class with CoroutineAccessors enabled

**URL:** <https://forums.swift.org/t/task-yield-never-resumes-when-having-a-borrowing-access-to-a-non-copyable-member-of-a-class-with-coroutineaccessors-enabled/89746>\
**Category:** Using Swift\
**Tags:** concurrency, noncopyable\
**Created:** [September 24, 2026, 1:14pm UTC](https://forums.swift.org/t/task-yield-never-resumes-when-having-a-borrowing-access-to-a-non-copyable-member-of-a-class-with-coroutineaccessors-enabled/89746 "2026-09-24T13:14:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Serika\_PHB](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/serika_phb/32/37091_2.png) [@Serika\_PHB](https://forums.swift.org/u/Serika_PHB)\
**Post date:** [September 24, 2026, 1:14pm UTC](https://forums.swift.org/t/task-yield-never-resumes-when-having-a-borrowing-access-to-a-non-copyable-member-of-a-class-with-coroutineaccessors-enabled/89746/1 "2026-09-24T13:14:09Z")

</div>

```swift
class C { 
    var v: UniqueBox<Int> = .init(1)
}

func test() async {
    let c = C()
    let span = c.v.span
    print("before yield")
    await Task.yield()
    print("resumed \(span[0])")
}

await test()

```

```swift
swiftc -enable-experimental-feature CoroutineAccessors main.swift
./main

```

When executing the codes above with CoroutineAccessors enabled, the `Task.yield` function never resumes and the whole process just gets stuck.

But if we remove the CoroutineAccessors feature flag, it works fine.

What's happening here?

---

<div class="post-metadata">

**Author:** ![gxlactuss](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/gxlactuss/32/46675_2.png) [@gxlactuss](https://forums.swift.org/u/gxlactuss)\
**Post date:** [September 24, 2026, 1:48pm UTC](https://forums.swift.org/t/task-yield-never-resumes-when-having-a-borrowing-access-to-a-non-copyable-member-of-a-class-with-coroutineaccessors-enabled/89746/2 "2026-09-24T13:48:37Z")

</div>

This seems to be a problem with the CoroutineAccessors feature being tested here rather than a problem with the code. The reason is that since class C is not final, the access to c.v is through an accessor coroutine which yields a borrow of the UniqueBox.  
Since span depends on that borrow, the coroutine suspends at the yield point through the await Task.yield(). Without the flag, the accessor uses the older \_read ABI which has its frame allocated in a caller provided buffer that can spill into the asynchronous frame. However, with the flag enabled, the accessor uses the newer yield\_once\_2 ABI which allocates its frame from the task allocator in asynchronous contexts.

Basically try making the class final.
