bangerang / swift-async-expectations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@MainActor isolation on expect functions

KaiOelfke opened this issue · comments

All the expect functions are @mainactor isolated and the async expression closures as well. I'm not sure, if this is always needed. The evaluate function uses an internal actor to protect the isFulfilled state. If I want to test some expression that has to run on the MainActor this is useful.

But for code that doesn't have to be isolated this requires MainActor isolation code to be added. I don't want to add this to the call site, if I don't actually need the isolation for data safety.

I think the async expression closures should also be @sendable ?

I forked the code and I'm experimenting with non isolated expect function overloads. Unfortunately this requires different names it seems. Apparently Swift doesn't support function overloading with and without @mainactor isolation.

I think annotating the async closures with @mainactor makes them Sendable. Agree that it would be nice to skip adding the @mainactor on the client side. Would it work to remove the MainActor as default and just mark the closures as sendable?

Yes, I think it should be possible to just mark the closure as required to be @sendable. I can take a look, when I have time.