@@ -48,9 +48,9 @@ public struct ObservableMacro {
48
48
return
49
49
"""
50
50
internal nonisolated func access<Member>(
51
- keyPath: KeyPath< \( observableType) , Member>
51
+ keyPath: KeyPath< \( observableType) , Member>
52
52
) {
53
- \( raw: registrarVariableName) .access(self, keyPath: keyPath)
53
+ \( raw: registrarVariableName) .access(self, keyPath: keyPath)
54
54
}
55
55
"""
56
56
}
@@ -59,10 +59,10 @@ public struct ObservableMacro {
59
59
return
60
60
"""
61
61
internal nonisolated func withMutation<Member, MutationResult>(
62
- keyPath: KeyPath< \( observableType) , Member>,
63
- _ mutation: () throws -> MutationResult
62
+ keyPath: KeyPath< \( observableType) , Member>,
63
+ _ mutation: () throws -> MutationResult
64
64
) rethrows -> MutationResult {
65
- try \( raw: registrarVariableName) .withMutation(of: self, keyPath: keyPath, mutation)
65
+ try \( raw: registrarVariableName) .withMutation(of: self, keyPath: keyPath, mutation)
66
66
}
67
67
"""
68
68
}
@@ -202,7 +202,7 @@ extension ObservableMacro: MemberMacro {
202
202
return [ ]
203
203
}
204
204
205
- let observableType = identified. name
205
+ let observableType = identified. name. trimmed
206
206
207
207
if declaration. isEnum {
208
208
// enumerations cannot store properties
@@ -294,7 +294,7 @@ public struct ObservationTrackedMacro: AccessorMacro {
294
294
) throws -> [ AccessorDeclSyntax ] {
295
295
guard let property = declaration. as ( VariableDeclSyntax . self) ,
296
296
property. isValidForObservation,
297
- let identifier = property. identifier else {
297
+ let identifier = property. identifier? . trimmed else {
298
298
return [ ]
299
299
}
300
300
@@ -306,24 +306,24 @@ public struct ObservationTrackedMacro: AccessorMacro {
306
306
"""
307
307
@storageRestrictions(initializes: _ \( identifier) )
308
308
init(initialValue) {
309
- _ \( identifier) = initialValue
309
+ _ \( identifier) = initialValue
310
310
}
311
311
"""
312
312
313
313
let getAccessor : AccessorDeclSyntax =
314
314
"""
315
315
get {
316
- access(keyPath: \\ . \( identifier) )
317
- return _ \( identifier)
316
+ access(keyPath: \\ . \( identifier) )
317
+ return _ \( identifier)
318
318
}
319
319
"""
320
320
321
321
let setAccessor : AccessorDeclSyntax =
322
322
"""
323
323
set {
324
- withMutation(keyPath: \\ . \( identifier) ) {
325
- _ \( identifier) = newValue
326
- }
324
+ withMutation(keyPath: \\ . \( identifier) ) {
325
+ _ \( identifier) = newValue
326
+ }
327
327
}
328
328
"""
329
329
0 commit comments