File tree 2 files changed +9
-1
lines changed
Sources/AssociatedObjectPlugin
Tests/AssociatedObjectTests
2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -208,7 +208,8 @@ extension AssociatedObjectMacro: AccessorMacro {
208
208
identifier: identifier,
209
209
type: type,
210
210
policy: policy,
211
- associatedKey: associatedKey,
211
+ associatedKey: associatedKey,
212
+ hasDefaultValue: defaultValue != nil ,
212
213
willSet: binding. willSet,
213
214
didSet: binding. didSet
214
215
)
@@ -306,6 +307,7 @@ extension AssociatedObjectMacro {
306
307
type: TypeSyntax ,
307
308
policy: ExprSyntax ,
308
309
associatedKey: ExprSyntax ,
310
+ hasDefaultValue: Bool ,
309
311
`willSet`: AccessorDeclSyntax ? ,
310
312
`didSet`: AccessorDeclSyntax ?
311
313
) -> AccessorDeclSyntax {
@@ -336,6 +338,11 @@ extension AssociatedObjectMacro {
336
338
\( policy)
337
339
)
338
340
"""
341
+ if type. isOptional, hasDefaultValue {
342
+ """
343
+ self.__associated_ \( identifier. trimmed) IsSet = true
344
+ """
345
+ }
339
346
340
347
if let didSet = `didSet`,
341
348
let body = didSet. body {
Original file line number Diff line number Diff line change @@ -385,6 +385,7 @@ final class AssociatedObjectTests: XCTestCase {
385
385
newValue,
386
386
.retain(.nonatomic)
387
387
)
388
+ self.__associated_stringIsSet = true
388
389
}
389
390
}
390
391
You can’t perform that action at this time.
0 commit comments