Skip to content

Commit fd23985

Browse files
committed
[Macros] Fix source location for declaration syntax of attached macros
Use the correct source file. Previously, the location of declaration macros were sent to executable plugins as if the were in the source file of the attribute. This was problematic when the attribute is synsthesized by a macro. When source location were used in the plugin, for example, as a diagnostic location, it ended up with an unknown location. (cherry picked from commit 921555a)
1 parent a1f9a6b commit fd23985

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/ASTGen/Sources/ASTGen/Macros.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ func expandAttachedMacroIPC(
888888

889889
let declSyntax = PluginMessage.Syntax(
890890
syntax: Syntax(declarationNode),
891-
in: customAttrSourceFilePtr
891+
in: declarationSourceFilePtr
892892
)!
893893

894894
let parentDeclSyntax: PluginMessage.Syntax?

test/Macros/DebugDescription/error_complex_implementation.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
// RUN: %empty-directory(%t)
44
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -verify -plugin-path %swift-plugin-dir
5+
// RUN: %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -verify -external-plugin-path %swift-plugin-dir#%swift-plugin-server
56

67
@DebugDescription
78
struct MyStruct {

0 commit comments

Comments
 (0)