I am using Version 15.0 beta 6 (15A5219j), it seems the breakpoints work on the expression macro but does not work for peer macro.
Code:
public struct StringifyMacro: ExpressionMacro {
public static func expansion(
of node: some FreestandingMacroExpansionSyntax,
in context: some MacroExpansionContext
) -> ExprSyntax {
guard let argument = node.argumentList.first?.expression else {
fatalError("compiler bug: the macro does not have any arguments")
}
// breakpoint 1 here
return "(\(argument), \(literal: argument.description))"
}
}
public struct MyPeerMacro: PeerMacro {
public static func expansion(of node: SwiftSyntax.AttributeSyntax, providingPeersOf declaration: some SwiftSyntax.DeclSyntaxProtocol, in context: some SwiftSyntaxMacros.MacroExpansionContext) throws -> [SwiftSyntax.DeclSyntax] {
guard let firstChild = node.children(viewMode: .all).first else {
fatalError("!!!")
}
// breakpoint 2 here
return []
}
}
When do you expect the breakpoint to get hit? While you run a test with assertMacroExpansion (in which case I don’t see any reason why it shouldn’t be hit) or while you are compiling the code (in which case the macro plugin doesn’t run with a debugger attached, so no breakpoint should be hit)?