Skip to content

Commit dd2ee8f

Browse files
swift-cinatecook1000
authored andcommitted
Merge pull request swiftlang#67289 from natecook1000/observation_peer_macros
[Observation] Switch to peer instead of arbitrary macros
1 parent 7fb670d commit dd2ee8f

File tree

3 files changed

+4
-15
lines changed

3 files changed

+4
-15
lines changed

lib/Macros/Sources/ObservationMacros/ObservableMacro.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,6 @@ extension ObservableMacro: MemberMacro {
225225
declaration.addIfNeeded(ObservableMacro.accessFunction(observableType), to: &declarations)
226226
declaration.addIfNeeded(ObservableMacro.withMutationFunction(observableType), to: &declarations)
227227

228-
#if !OBSERVATION_SUPPORTS_PEER_MACROS
229-
let storedInstanceVariables = declaration.definedVariables.filter { $0.isValidForObservation }
230-
for property in storedInstanceVariables {
231-
if property.hasMacroApplication(ObservableMacro.ignoredMacroName) { continue }
232-
let storage = DeclSyntax(property.privatePrefixed("_", addingAttribute: ObservableMacro.ignoredAttribute))
233-
declaration.addIfNeeded(storage, to: &declarations)
234-
}
235-
#endif
236-
237228
return declarations
238229
}
239230
}

stdlib/public/Observation/Sources/Observation/Observable.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,15 @@ public protocol Observable { }
1616
#if $Macros && hasAttribute(attached)
1717

1818
@available(SwiftStdlib 5.9, *)
19-
#if OBSERVATION_SUPPORTS_PEER_MACROS
2019
@attached(member, names: named(_$observationRegistrar), named(access), named(withMutation))
21-
#else
22-
@attached(member, names: named(_$observationRegistrar), named(access), named(withMutation), arbitrary)
23-
#endif
2420
@attached(memberAttribute)
2521
@attached(extension, conformances: Observable)
2622
public macro Observable() =
2723
#externalMacro(module: "ObservationMacros", type: "ObservableMacro")
2824

2925
@available(SwiftStdlib 5.9, *)
3026
@attached(accessor, names: named(init), named(get), named(set))
31-
#if OBSERVATION_SUPPORTS_PEER_MACROS
3227
@attached(peer, names: prefixed(_))
33-
#endif
3428
public macro ObservationTracked() =
3529
#externalMacro(module: "ObservationMacros", type: "ObservationTrackedMacro")
3630

test/stdlib/Observation/Observable.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ struct Validator {
207207

208208

209209
let suite = TestSuite("Observable")
210+
211+
suite.test("only instantiate") {
212+
let test = MiddleNamePerson()
213+
}
210214

211215
suite.test("unobserved value changes") {
212216
let test = MiddleNamePerson()

0 commit comments

Comments
 (0)