Skip to content

Commit bc7c257

Browse files
authored
Update to swift-syntax 600.0.0 (#959)
1 parent d44a56f commit bc7c257

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ var dependencies: [Package.Dependency] {
6565
branch: "main"),
6666
.package(
6767
url: "https://github.com/swiftlang/swift-syntax",
68-
from: "600.0.0-latest")
68+
from: "600.0.0")
6969
]
7070
}
7171
}

Sources/FoundationMacros/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ if(NOT SwiftSyntax_FOUND)
4343
# If building at desk, check out and link against the SwiftSyntax repo's targets
4444
FetchContent_Declare(SwiftSyntax
4545
GIT_REPOSITORY https://github.com/swiftlang/swift-syntax.git
46-
GIT_TAG 4c6cc0a3b9e8f14b3ae2307c5ccae4de6167ac2c) # 600.0.0-prerelease-2024-06-12
46+
GIT_TAG 600.0.0)
4747
FetchContent_MakeAvailable(SwiftSyntax)
4848
else()
4949
message(STATUS "SwiftSyntax_DIR provided, using swift-syntax from ${SwiftSyntax_DIR}")

Tests/FoundationMacrosTests/MacroTestUtilities.swift

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ struct DiagnosticTest : ExpressibleByStringLiteral, Hashable, CustomStringConver
4646

4747
var mappedToExpression: Self {
4848
DiagnosticTest(
49-
message._replacing("Predicate", with: "Expression")._replacing("predicate", with: "expression"),
49+
message.replacing("Predicate", with: "Expression").replacing("predicate", with: "expression"),
5050
fixIts: fixIts.map {
51-
FixItTest($0.message, result: $0.result._replacing("#Predicate", with: "#Expression"))
51+
FixItTest($0.message, result: $0.result.replacing("#Predicate", with: "#Expression"))
5252
}
5353
)
5454
}
@@ -125,7 +125,9 @@ func AssertMacroExpansion(macros: [String : Macro.Type], testModuleName: String
125125
let origSourceFile = Parser.parse(source: source)
126126
let expandedSourceFile: Syntax
127127
do {
128-
expandedSourceFile = try OperatorTable.standardOperators.foldAll(origSourceFile).expand(macros: macros, in: context)
128+
expandedSourceFile = try OperatorTable.standardOperators.foldAll(origSourceFile).expand(macros: macros) { syntax in
129+
BasicMacroExpansionContext(sharingWith: context, lexicalContext: [syntax])
130+
}
129131
} catch {
130132
XCTFail("Operator folding on input source failed with error \(error)")
131133
return
@@ -157,22 +159,10 @@ func AssertPredicateExpansion(_ source: String, _ result: String = "", diagnosti
157159
)
158160
AssertMacroExpansion(
159161
macros: ["Expression" : FoundationMacros.ExpressionMacro.self],
160-
source._replacing("#Predicate", with: "#Expression"),
161-
result._replacing(".Predicate", with: ".Expression"),
162+
source.replacing("#Predicate", with: "#Expression"),
163+
result.replacing(".Predicate", with: ".Expression"),
162164
diagnostics: Set(diagnostics.map(\.mappedToExpression)),
163165
file: file,
164166
line: line
165167
)
166168
}
167-
168-
extension String {
169-
func _replacing(_ text: String, with other: String) -> Self {
170-
if #available(macOS 13.0, *) {
171-
// Use the stdlib API if available
172-
self.replacing(text, with: other)
173-
} else {
174-
// Use the Foundation API on older OSes
175-
self.replacingOccurrences(of: text, with: other, options: [.literal])
176-
}
177-
}
178-
}

0 commit comments

Comments
 (0)