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()
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.