File tree 3 files changed +9
-7
lines changed
Sources/AssociatedObjectPlugin
Tests/AssociatedObjectTests
3 files changed +9
-7
lines changed Original file line number Diff line number Diff line change 1
1
Pod ::Spec . new do |s |
2
2
3
3
s . name = "AssociatedObject"
4
- s . version = "0.8.0 "
4
+ s . version = "0.10.1 "
5
5
s . summary = "Swift Macro for allowing variable declarations even in class extensions."
6
6
7
7
s . description = <<-DESC
Original file line number Diff line number Diff line change @@ -228,8 +228,10 @@ extension AssociatedObjectMacro {
228
228
policy: ExprSyntax ,
229
229
defaultValue: ExprSyntax ?
230
230
) -> AccessorDeclSyntax {
231
- let typeWithoutOptional = if let type = type. as ( ImplicitlyUnwrappedOptionalTypeSyntax . self) {
232
- type. wrappedType
231
+ let typeWithoutOptional = if let type = type. as ( ImplicitlyUnwrappedOptionalTypeSyntax . self) {
232
+ type. wrappedType
233
+ } else if let type = type. as ( OptionalTypeSyntax . self) {
234
+ type. wrappedType
233
235
} else {
234
236
type
235
237
}
@@ -253,7 +255,7 @@ extension AssociatedObjectMacro {
253
255
return getAssociatedObject(
254
256
self,
255
257
\( associatedKey)
256
- ) as! \( typeWithoutOptional. trimmed)
258
+ ) as? \( typeWithoutOptional. trimmed)
257
259
}
258
260
"""
259
261
} else if let defaultValue {
Original file line number Diff line number Diff line change @@ -246,7 +246,7 @@ final class AssociatedObjectTests: XCTestCase {
246
246
getAssociatedObject(
247
247
self,
248
248
Self.__associated_stringKey
249
- ) as? String?
249
+ ) as? String
250
250
?? nil
251
251
}
252
252
set {
@@ -356,7 +356,7 @@ final class AssociatedObjectTests: XCTestCase {
356
356
return getAssociatedObject(
357
357
self,
358
358
Self.__associated_stringKey
359
- ) as! String?
359
+ ) as? String
360
360
}
361
361
}
362
362
set {
@@ -481,7 +481,7 @@ final class AssociatedObjectTests: XCTestCase {
481
481
getAssociatedObject(
482
482
self,
483
483
Self.__associated_boolKey
484
- ) as? Bool?
484
+ ) as? Bool
485
485
?? nil
486
486
}
487
487
set {
You can’t perform that action at this time.
0 commit comments