Skip to content

Remove unnecessary @ObservationIgnored in 0395-observability.md#3241

Open
ptrkstr wants to merge 1 commit intoswiftlang:mainfrom
ptrkstr:patch-1
Open

Remove unnecessary @ObservationIgnored in 0395-observability.md#3241
ptrkstr wants to merge 1 commit intoswiftlang:mainfrom
ptrkstr:patch-1

Conversation

@ptrkstr
Copy link
Copy Markdown

@ptrkstr ptrkstr commented Apr 14, 2026

let properties don’t need @ObservationIgnored, the @Observable macro already skips them entirely. The macro checks isImmutable (whether the binding uses let) and excludes immutable properties from observation tracking via isValidForObservation:

  var isValidForObservation: Bool {
    !isComputed && isInstance && !isImmutable && identifier != nil
  }

No accessors, backing storage, or mutation notifications are generated for let properties regardless of whether @ObservationIgnored is present.

Sources:

let properties don’t need `@ObservationIgnored`, the `@Observable` macro already skips them entirely. The macro checks `isImmutable` (whether the binding uses `let`) and excludes immutable properties from observation tracking via `isValidForObservation`:
```swift
  var isValidForObservation: Bool {
    !isComputed && isInstance && !isImmutable && identifier != nil
  }
```
No accessors, backing storage, or mutation notifications are generated for `let` properties regardless of whether `@ObservationIgnored` is present.

Sources:
- isImmutable check: https://github.com/swiftlang/swift/blob/main/lib/Macros/Sources/ObservationMacros/Extensions.swift#L95-L97
- isValidForObservation gate: https://github.com/swiftlang/swift/blob/main/lib/Macros/Sources/ObservationMacros/ObservableMacro.swift#L238-L240
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant