A question about Actor

I know that we cannot modify isolated properties from outside the actor
However, when the property is a reference type, we can modify the property value of the reference instance.
In this case, if I only modify the attribute value of the reference instance in the following way, can I avoid data races? thanks.

class Settings {
    var name:String
}
actor Test {
    var settings:Settings
}

let test = Test()
await  test.settings.name = "hello"

Yes, if you could write that code without the compiler complaining, then access of that restricted kind would be safe from data races. However:

await test.settings.name = "hello"
                ^ warning: non-sendable type 'Settings' in implicitly asynchronous access 
                   to actor-isolated property 'settings' cannot cross actor boundary

(with strict concurrency checking turned on).

But the compiler's gonna complain. If not now, then later. :slight_smile:

3 Likes

Since strict concurrency check was not turned on and therefore did not get a warning, I mistakenly assumed it was allowed.
Thank you for your answer!