Skip to content

Commit 9cafa60

Browse files
authored
Merge pull request #628 from apple/revert-623-5.9-features-in-5.9
Revert "[5.9 🍒] Add support for various new 5.9 features."
2 parents 83248b4 + f1fa0a2 commit 9cafa60

9 files changed

+5
-161
lines changed

Sources/SwiftFormat/Core/ModifierListSyntax+Convenience.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ extension DeclModifierListSyntax {
1717
var accessLevelModifier: DeclModifierSyntax? {
1818
for modifier in self {
1919
switch modifier.name.tokenKind {
20-
case .keyword(.public), .keyword(.private), .keyword(.fileprivate), .keyword(.internal),
21-
.keyword(.package):
20+
case .keyword(.public), .keyword(.private), .keyword(.fileprivate), .keyword(.internal):
2221
return modifier
2322
default:
2423
continue

Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2293,7 +2293,6 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
22932293

22942294
override func visit(_ node: GenericParameterSyntax) -> SyntaxVisitorContinueKind {
22952295
before(node.firstToken(viewMode: .sourceAccurate), tokens: .open)
2296-
after(node.eachKeyword, tokens: .break)
22972296
after(node.colon, tokens: .break)
22982297
if let trailingComma = node.trailingComma {
22992298
after(trailingComma, tokens: .close, .break(.same))
@@ -2313,28 +2312,6 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
23132312
return .visitChildren
23142313
}
23152314

2316-
override func visit(_ node: PackElementExprSyntax) -> SyntaxVisitorContinueKind {
2317-
// `each` cannot be separated from the following token, or it is parsed as an identifier itself.
2318-
after(node.eachKeyword, tokens: .space)
2319-
return .visitChildren
2320-
}
2321-
2322-
override func visit(_ node: PackElementTypeSyntax) -> SyntaxVisitorContinueKind {
2323-
// `each` cannot be separated from the following token, or it is parsed as an identifier itself.
2324-
after(node.eachKeyword, tokens: .space)
2325-
return .visitChildren
2326-
}
2327-
2328-
override func visit(_ node: PackExpansionExprSyntax) -> SyntaxVisitorContinueKind {
2329-
after(node.repeatKeyword, tokens: .break)
2330-
return .visitChildren
2331-
}
2332-
2333-
override func visit(_ node: PackExpansionTypeSyntax) -> SyntaxVisitorContinueKind {
2334-
after(node.repeatKeyword, tokens: .break)
2335-
return .visitChildren
2336-
}
2337-
23382315
override func visit(_ node: ExpressionPatternSyntax) -> SyntaxVisitorContinueKind {
23392316
return .visitChildren
23402317
}
@@ -2504,27 +2481,6 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
25042481
return .visitChildren
25052482
}
25062483

2507-
override func visit(_ node: ConsumeExprSyntax) -> SyntaxVisitorContinueKind {
2508-
// The `consume` keyword cannot be separated from the following token or it will be parsed as
2509-
// an identifier.
2510-
after(node.consumeKeyword, tokens: .space)
2511-
return .visitChildren
2512-
}
2513-
2514-
override func visit(_ node: CopyExprSyntax) -> SyntaxVisitorContinueKind {
2515-
// The `copy` keyword cannot be separated from the following token or it will be parsed as an
2516-
// identifier.
2517-
after(node.copyKeyword, tokens: .space)
2518-
return .visitChildren
2519-
}
2520-
2521-
override func visit(_ node: DiscardStmtSyntax) -> SyntaxVisitorContinueKind {
2522-
// The `discard` keyword cannot be separated from the following token or it will be parsed as
2523-
// an identifier.
2524-
after(node.discardKeyword, tokens: .space)
2525-
return .visitChildren
2526-
}
2527-
25282484
override func visit(_ node: InheritanceClauseSyntax) -> SyntaxVisitorContinueKind {
25292485
// Normally, the open-break is placed before the open token. In this case, it's intentionally
25302486
// ordered differently so that the inheritance list can start on the current line and only

Sources/SwiftFormat/Rules/AlwaysUseLiteralForEmptyCollectionInit.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ public final class AlwaysUseLiteralForEmptyCollectionInit : SyntaxFormatRule {
166166
}
167167

168168
private func getLiteralType(_ arrayLiteral: ArrayExprSyntax) -> TypeSyntax? {
169-
guard arrayLiteral.elements.count == 1 else {
169+
guard let elementExpr = arrayLiteral.elements.firstAndOnly,
170+
elementExpr.is(ArrayElementSyntax.self) else {
170171
return nil
171172
}
172173

Sources/SwiftFormat/Rules/NoAccessLevelOnExtensionDeclaration.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public final class NoAccessLevelOnExtensionDeclaration: SyntaxFormatRule {
3232
var result = node
3333

3434
switch keyword {
35-
// Public, private, fileprivate, or package keywords need to be moved to members
36-
case .public, .private, .fileprivate, .package:
35+
// Public, private, or fileprivate keywords need to be moved to members
36+
case .public, .private, .fileprivate:
3737
// The effective access level of the members of a `private` extension is `fileprivate`, so
3838
// we have to update the keyword to ensure that the result is correct.
3939
var accessKeywordToAdd = accessKeyword

Tests/SwiftFormatTests/PrettyPrint/ConsumeExprTests.swift

Lines changed: 0 additions & 14 deletions
This file was deleted.

Tests/SwiftFormatTests/PrettyPrint/CopyExprSyntax.swift

Lines changed: 0 additions & 14 deletions
This file was deleted.

Tests/SwiftFormatTests/PrettyPrint/DiscardStmtTests.swift

Lines changed: 0 additions & 13 deletions
This file was deleted.

Tests/SwiftFormatTests/PrettyPrint/ParameterPackTests.swift

Lines changed: 0 additions & 46 deletions
This file was deleted.

Tests/SwiftFormatTests/Rules/NoAccessLevelOnExtensionDeclarationTests.swift

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -128,31 +128,6 @@ final class NoAccessLevelOnExtensionDeclarationTests: LintOrFormatRuleTestCase {
128128
)
129129
}
130130

131-
func testPackageAccessLevel() {
132-
assertFormatting(
133-
NoAccessLevelOnExtensionDeclaration.self,
134-
input: """
135-
1️⃣package extension Foo {
136-
2️⃣func f() {}
137-
}
138-
""",
139-
expected: """
140-
extension Foo {
141-
package func f() {}
142-
}
143-
""",
144-
findings: [
145-
FindingSpec(
146-
"1️⃣",
147-
message: "move this 'package' access modifier to precede each member inside this extension",
148-
notes: [
149-
NoteSpec("2️⃣", message: "add 'package' access modifier to this declaration"),
150-
]
151-
),
152-
]
153-
)
154-
}
155-
156131
func testPrivateIsEffectivelyFileprivate() {
157132
assertFormatting(
158133
NoAccessLevelOnExtensionDeclaration.self,

0 commit comments

Comments
 (0)