Skip to content

Commit 6b9d391

Browse files
authored
Merge pull request swiftlang#211 from dabelknap/attributed-types
Fix spacing for attributed types
2 parents 9bb92d4 + bcbe041 commit 6b9d391

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

Sources/SwiftFormatPrettyPrint/TokenStreamCreator.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,7 @@ private final class TokenStreamCreator: SyntaxVisitor {
10541054
}
10551055

10561056
override func visit(_ node: AttributedTypeSyntax) {
1057+
arrangeAttributeList(node.attributes)
10571058
after(node.specifier, tokens: .break)
10581059
super.visit(node)
10591060
}

Tests/SwiftFormatPrettyPrintTests/FunctionDeclTests.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,4 +525,31 @@ public class FunctionDeclTests: PrettyPrintTestCase {
525525
"""
526526
assertPrettyPrintEqual(input: input, expected: expected, linelength: 23)
527527
}
528+
529+
public func testAttributedTypes() {
530+
let input =
531+
"""
532+
func MyFun(myvar: @escaping MyType)
533+
534+
func MyFun(myvar1: Int, myvar2: Double, myvar3: @escaping MyType) -> Bool {
535+
// do stuff
536+
return false
537+
}
538+
"""
539+
540+
let expected =
541+
"""
542+
func MyFun(myvar: @escaping MyType)
543+
544+
func MyFun(
545+
myvar1: Int, myvar2: Double,
546+
myvar3: @escaping MyType
547+
) -> Bool {
548+
// do stuff
549+
return false
550+
}
551+
552+
"""
553+
assertPrettyPrintEqual(input: input, expected: expected, linelength: 35)
554+
}
528555
}

0 commit comments

Comments
 (0)