I declared the expression Macro and I have retrieved the parameters from FreestandingMacroExpansionSyntax as below.
Macro declaration
public macro sfImage<T>(_ value: String) -> T
Retrieve parameters
public struct sfImage: 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")
}
// Return Image or UIImage based on return type.
return ""
}
}
I would like to get the return type of Macro by parsing FreestandingMacroExpansionSyntax. Please suggest how can we retrieve the return type of macro. Thanks in advance.