diff --git a/Package.swift b/Package.swift index 005f39636..12b28d0bd 100644 --- a/Package.swift +++ b/Package.swift @@ -65,7 +65,7 @@ var dependencies: [Package.Dependency] { branch: "main"), .package( url: "https://github.com/swiftlang/swift-syntax", - from: "600.0.0-latest") + from: "600.0.0") ] } } diff --git a/Sources/FoundationMacros/CMakeLists.txt b/Sources/FoundationMacros/CMakeLists.txt index 9532496ff..98b90c0df 100644 --- a/Sources/FoundationMacros/CMakeLists.txt +++ b/Sources/FoundationMacros/CMakeLists.txt @@ -43,7 +43,7 @@ if(NOT SwiftSyntax_FOUND) # If building at desk, check out and link against the SwiftSyntax repo's targets FetchContent_Declare(SwiftSyntax GIT_REPOSITORY https://github.com/swiftlang/swift-syntax.git - GIT_TAG 4c6cc0a3b9e8f14b3ae2307c5ccae4de6167ac2c) # 600.0.0-prerelease-2024-06-12 + GIT_TAG 600.0.0) FetchContent_MakeAvailable(SwiftSyntax) else() message(STATUS "SwiftSyntax_DIR provided, using swift-syntax from ${SwiftSyntax_DIR}") diff --git a/Tests/FoundationMacrosTests/MacroTestUtilities.swift b/Tests/FoundationMacrosTests/MacroTestUtilities.swift index 8b7e1c6a8..285e70ce6 100644 --- a/Tests/FoundationMacrosTests/MacroTestUtilities.swift +++ b/Tests/FoundationMacrosTests/MacroTestUtilities.swift @@ -46,9 +46,9 @@ struct DiagnosticTest : ExpressibleByStringLiteral, Hashable, CustomStringConver var mappedToExpression: Self { DiagnosticTest( - message._replacing("Predicate", with: "Expression")._replacing("predicate", with: "expression"), + message.replacing("Predicate", with: "Expression").replacing("predicate", with: "expression"), fixIts: fixIts.map { - FixItTest($0.message, result: $0.result._replacing("#Predicate", with: "#Expression")) + FixItTest($0.message, result: $0.result.replacing("#Predicate", with: "#Expression")) } ) } @@ -125,7 +125,9 @@ func AssertMacroExpansion(macros: [String : Macro.Type], testModuleName: String let origSourceFile = Parser.parse(source: source) let expandedSourceFile: Syntax do { - expandedSourceFile = try OperatorTable.standardOperators.foldAll(origSourceFile).expand(macros: macros, in: context) + expandedSourceFile = try OperatorTable.standardOperators.foldAll(origSourceFile).expand(macros: macros) { syntax in + BasicMacroExpansionContext(sharingWith: context, lexicalContext: [syntax]) + } } catch { XCTFail("Operator folding on input source failed with error \(error)") return @@ -157,22 +159,10 @@ func AssertPredicateExpansion(_ source: String, _ result: String = "", diagnosti ) AssertMacroExpansion( macros: ["Expression" : FoundationMacros.ExpressionMacro.self], - source._replacing("#Predicate", with: "#Expression"), - result._replacing(".Predicate", with: ".Expression"), + source.replacing("#Predicate", with: "#Expression"), + result.replacing(".Predicate", with: ".Expression"), diagnostics: Set(diagnostics.map(\.mappedToExpression)), file: file, line: line ) } - -extension String { - func _replacing(_ text: String, with other: String) -> Self { - if #available(macOS 13.0, *) { - // Use the stdlib API if available - self.replacing(text, with: other) - } else { - // Use the Foundation API on older OSes - self.replacingOccurrences(of: text, with: other, options: [.literal]) - } - } -}