sfba.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
A Mastodon instance for the San Francisco Bay Area. Come on in and join us!

Server stats:

2.3K
active users

Doug Gregor

@objc @mattiem @ole The @MainActor attribute is the general thing, and if DispatchQueue.main returned a MainDispatchQueue type whose async method took a @MainActor closure, we’d be all set. The problem with this specific case is that DispatchQueue.main already has a type (DispatchQueue), and you can’t change that type without affecting source compatibility. So you would need some generalization that tries to carry MainActor-ness along with the value. I suspect that such a generalization would generalize to, basically, just this API, so I didn’t pursue it. Given the choice between breaking source compatibility for DispatchQueue.main (which is everywhere), inventing a bespoke feature for these cases alone, or allow-listing this pattern to help more code “just work”… I think this was rhetorical right call. Maybe we should have also deprecated this pattern over to move to an API that does take a @MainActor closure, so the allow-list would become irrelevant over time.