You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -176,6 +177,9 @@ Attach to the property declarations of a struct that `@MemberwiseInit` is provid
176
177
*`@MemberwiseInit` on `actor`, `class`*(experimental)*
177
178
<br> Attachable to actor and class.
178
179
180
+
*`@_UncheckedMemberwiseInit`*(experimental)*
181
+
<br> Generate a memberwise initializer for all properties, regardless of access level, with reduced compile-time safety checks (compared to `@MemberwiseInit`).
`@_UncheckedMemberwiseInit` is an experimental macro that bypasses compile-time safety checks and strict access control enforcement. It generates an initializer for all properties of a type, regardless of their declared access levels. Use it judiciously.
608
+
609
+
Key characteristics:
610
+
611
+
- Generates an initializer that includes all properties, regardless of their declared access levels
612
+
- Includes attributed properties by default (differs from `@MemberwiseInit`)
613
+
- Follows the same usage pattern as `@MemberwiseInit`
614
+
615
+
Example:
616
+
617
+
```swift
618
+
@_UncheckedMemberwiseInit(.public)
619
+
publicstructAPIResponse: Codable {
620
+
publiclet id: String
621
+
@Monitoredinternalvar statusCode: Int
622
+
privatevar rawResponse: Data
623
+
624
+
// Computed properties and methods...
625
+
}
626
+
```
627
+
628
+
This yields a public initializer that includes all properties, regardless of their access level or attributes. Unlike `@MemberwiseInit`, this macro doesn't require `@Init` annotations or any other explicit opt-ins. The resulting initializer is:
0 commit comments