Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public final class UseSingleLinePropertyGetter: SyntaxFormatRule {
let body = acc.body,
accessors.count == 1,
acc.accessorSpecifier.tokenKind == .keyword(.get),
acc.attributes.isEmpty,
acc.modifier == nil,
acc.effectSpecifiers == nil
else { return node }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,30 @@ final class UseSingleLinePropertyGetterTests: LintOrFormatRuleTestCase {
]
)
}

func testGetterWithAttributedAccessorShouldBePreserved() {
assertFormatting(
UseSingleLinePropertyGetter.self,
input: """
struct Foo {
var value: Int {
@_lifetime(borrow self)
get {
return 1
}
}
}
""",
expected: """
struct Foo {
var value: Int {
@_lifetime(borrow self)
get {
return 1
}
}
}
"""
)
}
}