Keep notification tokens out of observation

The two observer tokens carried an isolation annotation the compiler
reported as having no effect, while rejecting the plain `nonisolated` it
suggested in its place. Both follow from `@Observable`: the macro rewrites
stored properties into computed accessors, where `unsafe` means nothing
and `nonisolated` is not allowed at all.

They are notification tokens, written on the main actor and read once in
deinit. Nothing renders them, so nothing should be tracking them. Marking
them ignored lets the annotation apply to a real stored property again
and settles the warning by removing the reason it appeared.
This commit is contained in:
Arkadiusz Fal
2026-09-01 23:53:01 +02:00
parent abd0f8ddbb
commit b1b7dcd10a

View File

@@ -67,8 +67,14 @@ final class CredentialIdentityScope {
private let retryDelay: @Sendable (Int) async -> Void
/// Written only on the main actor; read in `deinit`, which runs after the
/// last reference is gone and so cannot race with it.
private nonisolated(unsafe) var identityChangeObserver: NSObjectProtocol?
private nonisolated(unsafe) var cloudKitAccountObserver: NSObjectProtocol?
///
/// Kept out of observation deliberately. These are notification tokens, not
/// state anything renders, and `@Observable` would rewrite them into
/// computed accessors — which is what made the compiler report the
/// isolation annotation as having no effect while also refusing the plain
/// `nonisolated` it suggested.
@ObservationIgnored private nonisolated(unsafe) var identityChangeObserver: NSObjectProtocol?
@ObservationIgnored private nonisolated(unsafe) var cloudKitAccountObserver: NSObjectProtocol?
private static let cacheKey = "credentialIdentityScopeCache"