A friend told me this might be a bug and to mention it here.
I'm creating a new async context using SwiftUI's .task { } modifier, which is asserted to be on the main queue, then stays on the main queue after the method call, but then isn't on the main queue after getting the URLResponse back from bytes(for:):
Where is this startDownload function defined; is it actually guaranteed to be on the main actor or just happened to be so -- if the latter, then there is no guarantee where it'll hop back.
(Can you show the type declaration of where this function is defined in?)
Only functions and/or types annotated with @MainActor are actually guaranteed to run on the main actor. Otherwise it's no-one's business "where" the actor executes. If it would be in a type that is @MainActor I'd expect it to hope back indeed.
btw, considering that wasn't the main queue here but some other queue: what'd be wrong with hopping back to the original queue? is it because we don't want (why?) to retain the current queue to ensure it's still around by the time we need to hop back to it or is there another reason?