`withUnsafeCurrentTask` and inheritance of actor isolation

Just wanted to make sure, that I am not missing anything here.

There is this overload of withUnsafeCurrentTask that takes an async body and is of course async itself. However, it does not participate in actor isolation inheritance. Was this just an oversight, or deliberately left out?

If actor isolation inheritance is added, I guess the body should probably also be sending T, right?

If someone could confirm my suspicion, I'd be happy to create an issue and maybe also a PR.

I'd like to confirm what exactly do you mean with "participate in actor isolation inheritance"?

You mean adding an isolation: isolated (any Actor)? = #isolation parameter?

Adding these is a bit of a pain due to having to be careful around ABI but yeah I guess that could be done...

On the other hand... why would you need this? The unsafe API is used usually in contexts where you don't have any static current information, so I'm curious as to why you'd want that?

Yeah, sorry, should've clarified.

Hm, what do you mean by any static current information? I am not sure if this example is representative, but this fails to compile:

@MainActor
func foo(_: UnsafeCurrentTask?) async throws {}

@MainActor
func bar() async throws {
    try await withUnsafeCurrentTask { unsafeTask in // error: Sending main actor-isolated value of type '(UnsafeCurrentTask?) async throws -> ()' with later accesses to nonisolated context risks causing data races
        try await foo(unsafeTask)
    }
}

... because the closure expression is main actor isolated.