Skip to content

Commit 043fd58

Browse files
authored
Merge pull request #412 from allevato/recent-main-fixes
Fix recent breakages due to changes in swift-syntax main.
2 parents 2ce90d3 + 90cb1e8 commit 043fd58

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

Sources/SwiftFormatPrettyPrint/TokenStreamCreator.swift

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,9 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
764764
}
765765

766766
override func visit(_ node: YieldStmtSyntax) -> SyntaxVisitorContinueKind {
767-
after(node.yieldKeyword, tokens: .break)
767+
// As of https://github.com/apple/swift-syntax/pull/895, the token following a `yield` keyword
768+
// *must* be on the same line, so we cannot break here.
769+
after(node.yieldKeyword, tokens: .space)
768770
return .visitChildren
769771
}
770772

@@ -1641,10 +1643,6 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
16411643
return .visitChildren
16421644
}
16431645

1644-
override func visit(_ node: ElseBlockSyntax) -> SyntaxVisitorContinueKind {
1645-
return .visitChildren
1646-
}
1647-
16481646
override func visit(_ node: ConditionElementSyntax) -> SyntaxVisitorContinueKind {
16491647
before(node.firstToken, tokens: .open)
16501648
if let comma = node.trailingComma {
@@ -2178,10 +2176,6 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
21782176
return .visitChildren
21792177
}
21802178

2181-
override func visit(_ node: ElseIfContinuationSyntax) -> SyntaxVisitorContinueKind {
2182-
return .visitChildren
2183-
}
2184-
21852179
override func visit(_ node: GenericWhereClauseSyntax) -> SyntaxVisitorContinueKind {
21862180
guard node.whereKeyword != node.lastToken else {
21872181
verbatimToken(Syntax(node))

Tests/SwiftFormatPrettyPrintTests/YieldStmtTests.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ final class YieldStmtTests: PrettyPrintTestCase {
1717
"""
1818
var foo: Int {
1919
_read {
20-
yield
21-
1234567890
20+
yield 1234567890
2221
}
2322
_modify {
2423
var someLongVariable =
2524
0
26-
yield
27-
&someLongVariable
25+
yield &someLongVariable
2826
}
2927
}
3028

0 commit comments

Comments
 (0)