The isolation checker currently does not understand the equivalence of the @SomeGlobalActor
and the instance, they're seen as separate isolations and therefore the issue.
The solution to your problem here specifically would be provided by Closure isolation control but that's not been implemented for 6.0, but it's still something we're interested in doing one way or another.
It'd look like this
nonisolated func update() {
Task { [isolated self] in
}
}
Alternatively, there were proposals flying around about improving the isolation checker to understand the equivalence of an instance of a global actor to the global actor itself... (under the assumptiuon that there is just ONE such instance; you could violate this promise though). So then your code would have worked as is.
Either solutions don't exist though.
Today what I'd do is: move the state out of this actor instance entirely -- it's only going to be used as the thread serialization mechanism, and utilize the fact that you have a global actor to put state on:
@MyGlobalActor
var timeStamp = Date.now
@globalActor
actor MyGlobalActor : GlobalActor {
nonisolated func update() {
Task { @MyGlobalActor in
timeStamp = .now
}
}
static let shared = MyGlobalActor()
}