Change to Global Actor Inference in Swift 6 Language Mode?

I originally asked this question directly on the HWS Slack but since I haven't received a response so far, I decided to also post it here. Question down below (what are your thoughts - am I missing something?):

I just came across this HWS article about global actor inference: https://www.hackingwithswift.com/quick-start/concurrency/understanding-how-global-actor-inference-works
In the beginning, there is disclaimer stating the following:

Global actor inference was enabled from Swift 5.5 through to Swift 5.10. It is disabled in Swift 6 language mode, so if you're building using Swift 6 language mode or later you can ignore all of the below.

Is this really true? If I create a new project (macOS Command Line Tool - just for testing purposes) in Xcode 16.1 global actor inference seems to work the same as it's described in the article. Consider the following example which compiles:

@MainActor
class Foo {}

class Bar: Foo { // Bar seems to still inherit @MainActor from Foo
  func callMainActorFunc() {
    someMainActorFunc()
  }
}

@MainActor
func someMainActorFunc() {}

And yes, I have enabled the Swift 6 Language Mode (see Screenshot). Note that I tested it on a machine running macOS 14 but I think this shouldn't matter here.
When searching online I only find SE-0401 which, as far as I can see, covers only actor inference in the context of property wrappers.
Any clarification would be greatly appreciated :slightly_smiling_face:.

Are there any changes to how global actor inference work when enabling the Swift 6 language mode?

If you go through the article, you see that it makes a clear case that this inference is off for extensions. So if you conform to a main actor-isolated protocol in extension, it won’t inherit isolation.

Property wrappers is another case that has been addressed. It had a lot of implicit effects, described in the proposal, so having it off allows you better to reason about the code.

Long story short, Swift 6 is more explicit in isolation terms when it comes to inheritance of this characteristic. But this also may lead to some types that were inferred as actor isolated in Swift 5 will no longer be such; you more likely shouldn’t worry about this, as more likely you get errors in such cases about isolation mismatch.

1 Like

Thanks for your reply.

If you go through the article, you see that it makes a clear case that this inference is off for extensions. So if you conform to a main actor-isolated protocol in extension, it won’t inherit isolation.

This is the current behaviour in Swift 5 language mode and it won't change when switching to Swift 6 language mode. Or what exactly did you mean?

Property wrappers is another case that has been addressed. It had a lot of implicit effects, described in the proposal, so having it off allows you better to reason about the code.

Yes, I guess my last question("Are there any changes to how global actor inference work when enabling the Swift 6 language mode?") was a bit misleading, as it's clear from SE-0401 that there is at least this change in Swift 6 language mode.

Long story short, Swift 6 is more explicit in isolation terms when it comes to inheritance of this characteristic

Is this somewhere documented in more detail? Or are you referring to SE-0401?