Skip to content

Commit 73a25ed

Browse files
authored
Merge pull request #65385 from ahoppen/ahoppen/5.9/no-deprecations
[5.9][Macros] Remove usages of deprecated methods in SwiftSyntaxMacros
2 parents 8ea75cc + 4375b8a commit 73a25ed

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

lib/ASTGen/Sources/ASTGen/SourceManager+MacroExpansionContext.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ extension SourceManager.MacroExpansionContext: MacroExpansionContext {
8888
of node: Node,
8989
at position: PositionInSyntaxNode,
9090
filePathMode: SourceLocationFilePathMode
91-
) -> SourceLocation? {
91+
) -> AbstractSourceLocation? {
9292
guard let (sourceFile, rootPosition) = sourceManager.rootSourceFile(of: node),
9393
let exportedSourceFile =
9494
sourceManager.exportedSourceFilesBySyntax[sourceFile]?.pointee
@@ -127,6 +127,6 @@ extension SourceManager.MacroExpansionContext: MacroExpansionContext {
127127

128128
// Do the location lookup.
129129
let converter = SourceLocationConverter(file: fileName, tree: sourceFile)
130-
return converter.location(for: rootPosition.advanced(by: offsetWithinSyntaxNode))
130+
return AbstractSourceLocation(converter.location(for: rootPosition.advanced(by: offsetWithinSyntaxNode)))
131131
}
132132
}

test/Macros/Inputs/syntax_macro_definitions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public struct FileIDMacro: ExpressionMacro {
4242
throw CustomError.message("can't find location for macro")
4343
}
4444

45-
let fileLiteral: ExprSyntax = "\(literal: sourceLoc.file)"
45+
let fileLiteral: ExprSyntax = "\(sourceLoc.file)"
4646
return fileLiteral
4747
}
4848
}
@@ -588,7 +588,7 @@ public struct AddExtMembers: MemberMacro {
588588
providingMembersOf decl: some DeclGroupSyntax,
589589
in context: some MacroExpansionContext
590590
) throws -> [DeclSyntax] {
591-
let uniqueClassName = context.createUniqueName("uniqueClass")
591+
let uniqueClassName = context.makeUniqueName("uniqueClass")
592592

593593
let instanceMethod: DeclSyntax =
594594
"""

test/Macros/macro_expand.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ func testAddBlocker(a: Int, b: Int, c: Int, oa: OnlyAdds) {
287287

288288
// Test source location information.
289289
func testSourceLocations(x: Int, yolo: Int, zulu: Int) {
290-
// CHECK-MACRO-PRINTED: Source range for LHS is MacroUser/macro_expand.swift: [[@LINE+3]]:5-[[@LINE+3]]:13
291-
// CHECK-MACRO-PRINTED: Source range for LHS is MacroUser/macro_expand.swift: [[@LINE+2]]:5-[[@LINE+2]]:6
290+
// CHECK-MACRO-PRINTED: Source range for LHS is "MacroUser/macro_expand.swift": [[@LINE+3]]:5-[[@LINE+3]]:13
291+
// CHECK-MACRO-PRINTED: Source range for LHS is "MacroUser/macro_expand.swift": [[@LINE+2]]:5-[[@LINE+2]]:6
292292
_ = #leftHandOperandFinder(
293293
x + yolo + zulu
294294
)

0 commit comments

Comments
 (0)