Task: Is order of task execution deterministic?

Hm... I think runtime function that I made to support Isolated synchronous deinit could be used for "enqueue, but don't wait" operation.

If we are already on the correct executor it executes the code immediately. Does this fit the desired semantics? And it expects function to take closure context as owned. So closure is effectively self-consuming. Not sure if it is possible to express this convention the type system. But if not it could be solved with a heap allocation and a thunk.

But I guess the main challenges actually is expressing in the type system closure type isolated on the actor instance. This introduces dependent types, which AFAIK, Swift does not support.

extension Actor {
   func perform(_ work: @self () -> Void) {
        _performOnExecutor(getCtx(work), getFunc(work), self.unownedExecutor)
   }
}

actor MyActor {
    var k: Int = 0
    func inc() { k += 1 }
}

let a = MyActor()
let b = MyActor()
let aWork: @a () -> Void = {
    a.inc() // No await, we are inside actor context of a
}

// Should be an error: cannot convert @a () -> Void to expected type @b () -> Void
// But Swift type system cannot do this atm.
b.perform(aWork)