Skip to content

Commit

Permalink
fix var setter with 'newValue'
Browse files Browse the repository at this point in the history
  • Loading branch information
NikSativa committed Oct 9, 2024
1 parent 798d54f commit a5d0b09
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public enum SpryableAccessorMacro: AccessorMacro {
)

result.append(
.init(accessorSpecifier: .keyword(.set), body: .init(statements: "return spryify(\"\(raw: name)_set\")"))
.init(accessorSpecifier: .keyword(.set), body: .init(statements: "return spryify(\"\(raw: name)_set\", arguments: newValue)"))
)
} else if let effectSpecifiers {
result.append(
Expand Down
11 changes: 9 additions & 2 deletions Tests/Helpers/Spryable+TestHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@ final class SpryableTestClass: @unchecked Sendable {
@SpryableFunc
static func getAStaticString() -> String

@SpryableVar(.set, .get)
var firstName: String
/// @SpryableVar(.set, .get)
var firstName: String {
get {
return spryify("firstName_get")
}
set {
return spryify("firstName_set", arguments: newValue)
}
}

@SpryableFunc
func getAString(string: String) -> String
Expand Down
10 changes: 5 additions & 5 deletions Tests/SpryableMacrosTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ final class SpryableMacrosTests: XCTestCase {
return spryify("barSet_get")
}
set {
return spryify("barSet_set")
return spryify("barSet_set", arguments: newValue)
}
}
static static var barAsyncThrows: Int {
Expand Down Expand Up @@ -226,15 +226,15 @@ final class SpryableMacrosTests: XCTestCase {
return spryify("barSet_get")
}
set {
return spryify("barSet_set")
return spryify("barSet_set", arguments: newValue)
}
}
public static var barThrows: Int {
get throws {
return spryify("barThrows_get")
}
set {
return spryify("barThrows_set")
return spryify("barThrows_set", arguments: newValue)
}
}
var barAsyncThrows: Int {
Expand Down Expand Up @@ -346,15 +346,15 @@ final class SpryableMacrosTests: XCTestCase {
return spryify("barSet_get")
}
set {
return spryify("barSet_set")
return spryify("barSet_set", arguments: newValue)
}
}
public static var barThrows: Int {
get throws {
return spryify("barThrows_get")
}
set {
return spryify("barThrows_set")
return spryify("barThrows_set", arguments: newValue)
}
}
var barAsyncThrows: Int {
Expand Down

0 comments on commit a5d0b09

Please sign in to comment.