Skip to content

Commit

Permalink
Correctly handle _modify accessor
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklockwood committed Jun 9, 2024
1 parent e51ce8a commit 89fa293
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Sources/FormattingHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2870,7 +2870,7 @@ extension Formatter {
["static", "class"].contains(string)
})
if let name = name, classOrStatic || !staticSelf {
processAccessors(["get", "set", "willSet", "didSet", "init"], for: name,
processAccessors(["get", "set", "willSet", "didSet", "init", "_modify"], for: name,
at: &index, localNames: localNames, members: members,
typeStack: &typeStack, closureStack: &closureStack,
membersByType: &membersByType,
Expand Down Expand Up @@ -3186,7 +3186,7 @@ extension Formatter {
token = tokens[nextIndex]
}
switch token.string {
case "get":
case "get", "_modify":
localNames.insert(name)
case "set", "init":
localNames.insert(name)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Inference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ private struct Inference {
prevIndex -= 1
}
if let name = name {
processAccessors(["get", "set", "willSet", "didSet", "init"], for: name,
processAccessors(["get", "set", "willSet", "didSet", "init", "_modify"], for: name,
at: &index, localNames: localNames, members: members,
typeStack: &typeStack, membersByType: &membersByType,
classMembersByType: &classMembersByType,
Expand Down
4 changes: 2 additions & 2 deletions Sources/ParsingHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ extension Formatter {

func isAccessorKeyword(at i: Int, checkKeyword: Bool = true) -> Bool {
guard !checkKeyword ||
["get", "set", "willSet", "didSet", "init"].contains(token(at: i)?.string ?? ""),
["get", "set", "willSet", "didSet", "init", "_modify"].contains(token(at: i)?.string ?? ""),
var prevIndex = index(of: .nonSpaceOrCommentOrLinebreak, before: i)
else {
return false
Expand Down Expand Up @@ -1120,7 +1120,7 @@ extension Formatter {
return true
}
return false
case "get", "set", "willSet", "didSet", "init":
case "get", "set", "willSet", "didSet", "init", "_modify":
return isAccessorKeyword(at: i, checkKeyword: false)
case "actor":
if last(.nonSpaceOrCommentOrLinebreak, before: i)?.isOperator(ofType: .infix) == true {
Expand Down

0 comments on commit 89fa293

Please sign in to comment.