Skip to content

Commit 93e4443

Browse files
authored
Merge pull request swiftlang#204 from dabelknap/composition-type
Add composition types
2 parents d22a24d + 00459f3 commit 93e4443

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

Sources/SwiftFormatPrettyPrint/TokenStreamCreator.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,14 @@ private final class TokenStreamCreator: SyntaxVisitor {
11911191
super.visit(node)
11921192
}
11931193

1194+
override func visit(_ node: CompositionTypeElementSyntax) {
1195+
if let ampersand = node.ampersand {
1196+
before(ampersand, tokens: .break)
1197+
after(ampersand, tokens: .space)
1198+
}
1199+
super.visit(node)
1200+
}
1201+
11941202
override func visit(_ node: DeclarationStmtSyntax) {
11951203
super.visit(node)
11961204
}
@@ -1397,10 +1405,6 @@ private final class TokenStreamCreator: SyntaxVisitor {
13971405
super.visit(node)
13981406
}
13991407

1400-
override func visit(_ node: CompositionTypeElementSyntax) {
1401-
super.visit(node)
1402-
}
1403-
14041408
override func visit(_ node: ConformanceRequirementSyntax) {
14051409
before(node.firstToken, tokens: .open)
14061410
after(node.colon, tokens: .break)

Tests/SwiftFormatPrettyPrintTests/FunctionDeclTests.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ public class FunctionDeclTests: PrettyPrintTestCase {
122122
print("Hello World")
123123
}
124124
125+
func myFun<S: T & U>(var1: S) {
126+
// do stuff
127+
}
128+
125129
func longerNameFun<ReallyLongTypeName: Conform, TypeName>(var1: ReallyLongTypeNAme, var2: TypeName) {
126130
let a = 123
127131
let b = 456
@@ -135,6 +139,10 @@ public class FunctionDeclTests: PrettyPrintTestCase {
135139
print("Hello World")
136140
}
137141
142+
func myFun<S: T & U>(var1: S) {
143+
// do stuff
144+
}
145+
138146
func longerNameFun<
139147
ReallyLongTypeName: Conform,
140148
TypeName

0 commit comments

Comments
 (0)