Skip to content

Commit 43e2026

Browse files
committed
[ASTGen] The 'extendedType' argument for attached macros does not have a
source location.
1 parent 81a1f64 commit 43e2026

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

lib/ASTGen/Sources/ASTGen/Macros.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ func expandAttachedMacroIPC(
849849
let extendedTypeSyntax: PluginMessage.Syntax?
850850
if (!qualifiedType.isEmpty) {
851851
let typeSyntax: TypeSyntax = "\(raw: qualifiedType)"
852-
extendedTypeSyntax = .init(syntax: Syntax(typeSyntax), in: parentDeclSourceFilePtr!)!
852+
extendedTypeSyntax = .init(syntax: Syntax(typeSyntax))!
853853
} else {
854854
extendedTypeSyntax = nil
855855
}

lib/ASTGen/Sources/ASTGen/PluginHost.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,4 +392,31 @@ extension PluginMessage.Syntax {
392392
line: loc.line,
393393
column: loc.column))
394394
}
395+
396+
init?(syntax: Syntax) {
397+
let kind: PluginMessage.Syntax.Kind
398+
switch true {
399+
case syntax.is(DeclSyntax.self): kind = .declaration
400+
case syntax.is(ExprSyntax.self): kind = .expression
401+
case syntax.is(StmtSyntax.self): kind = .statement
402+
case syntax.is(TypeSyntax.self): kind = .type
403+
case syntax.is(PatternSyntax.self): kind = .pattern
404+
case syntax.is(AttributeSyntax.self): kind = .attribute
405+
default: return nil
406+
}
407+
408+
let source = syntax.description
409+
410+
self.init(
411+
kind: kind,
412+
source: source,
413+
location: .init(
414+
fileID: "",
415+
fileName: "",
416+
offset: 0,
417+
line: 0,
418+
column: 0
419+
)
420+
)
421+
}
395422
}

0 commit comments

Comments
 (0)