Skip to content

Commit 64ba7ff

Browse files
authored
Merge pull request #67289 from natecook1000/observation_peer_macros
[Observation] Switch to peer instead of arbitrary macros
2 parents 33ccc00 + e68395c commit 64ba7ff

File tree

4 files changed

+5
-15
lines changed

4 files changed

+5
-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
@@ -40,11 +40,7 @@ public protocol Observable { }
4040
/// }
4141
/// }
4242
@available(SwiftStdlib 5.9, *)
43-
#if OBSERVATION_SUPPORTS_PEER_MACROS
4443
@attached(member, names: named(_$observationRegistrar), named(access), named(withMutation))
45-
#else
46-
@attached(member, names: named(_$observationRegistrar), named(access), named(withMutation), arbitrary)
47-
#endif
4844
@attached(memberAttribute)
4945
@attached(extension, conformances: Observable)
5046
public macro Observable() =
@@ -56,9 +52,7 @@ public macro Observable() =
5652
/// framework isn't necessary.
5753
@available(SwiftStdlib 5.9, *)
5854
@attached(accessor, names: named(init), named(get), named(set))
59-
#if OBSERVATION_SUPPORTS_PEER_MACROS
6055
@attached(peer, names: prefixed(_))
61-
#endif
6256
public macro ObservationTracked() =
6357
#externalMacro(module: "ObservationMacros", type: "ObservationTrackedMacro")
6458

test/stdlib/Observation/Observable.swift

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

210210

211211
let suite = TestSuite("Observable")
212+
213+
suite.test("only instantiate") {
214+
let test = MiddleNamePerson()
215+
}
212216

213217
suite.test("unobserved value changes") {
214218
let test = MiddleNamePerson()

test/stdlib/Observation/ObservableDiagnostics.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// REQUIRES: objc_interop
1111
// UNSUPPORTED: use_os_stdlib
1212
// UNSUPPORTED: back_deployment_runtime
13+
// REQUIRES: rdar112623492
1314

1415
import Observation
1516

0 commit comments

Comments
 (0)