Skip to content

Commit 4209297

Browse files
authored
Merge pull request #65141 from kimdv/kimdv/remove-ComputedLocation
2 parents d738834 + b569879 commit 4209297

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

lib/ASTGen/Sources/ASTGen/PluginHost.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ extension PluginMessage.Syntax {
352352
fileID: fileID,
353353
fileName: fileName,
354354
offset: loc.offset,
355-
line: loc.line!,
356-
column: loc.column!))
355+
line: loc.line,
356+
column: loc.column))
357357
}
358358
}

test/Macros/Inputs/syntax_macro_definitions.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,11 @@ public struct FileIDMacro: ExpressionMacro {
3838
of macro: Node,
3939
in context: Context
4040
) throws -> ExprSyntax {
41-
guard let sourceLoc = context.location(of: macro),
42-
let fileID = sourceLoc.file
43-
else {
41+
guard let sourceLoc = context.location(of: macro) else {
4442
throw CustomError.message("can't find location for macro")
4543
}
4644

47-
let fileLiteral: ExprSyntax = "\(literal: fileID)"
45+
let fileLiteral: ExprSyntax = "\(literal: sourceLoc.file)"
4846
return fileLiteral.with(\.leadingTrivia, macro.leadingTrivia)
4947
}
5048
}
@@ -724,7 +722,7 @@ public enum LeftHandOperandFinderMacro: ExpressionMacro {
724722
fatalError("missing source location information")
725723
}
726724

727-
print("Source range for LHS is \(lhsStartLoc.file!): \(lhsStartLoc.line!):\(lhsStartLoc.column!)-\(lhsEndLoc.line!):\(lhsEndLoc.column!)")
725+
print("Source range for LHS is \(lhsStartLoc.file): \(lhsStartLoc.line):\(lhsStartLoc.column)-\(lhsEndLoc.line):\(lhsEndLoc.column)")
728726

729727
return .visitChildren
730728
}

0 commit comments

Comments
 (0)