-
Notifications
You must be signed in to change notification settings - Fork 447
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description
@attached(conformance)
public macro demonstration() = #externalMacro(module: "WWDC23Macros", type: "DemostrationMacro")
extension DemostrationMacro: ConformanceMacro {
public static func expansion<Declaration, Context>(
of node: AttributeSyntax,
providingConformancesOf declaration: Declaration,
in context: Context
) throws -> [(TypeSyntax, GenericWhereClauseSyntax?)] where Declaration : DeclGroupSyntax, Context : MacroExpansionContext {
return [("DemonstrationProtocol", nil)]
}
@main
struct WWDCHelperPlugin: CompilerPlugin {
let providingMacros: [Macro.Type] = [
DemostrationMacro.self
]
}
// in Test file
let testMacros: [String: Macro.Type] = [
"demonstration": DemostrationMacro.self,
]
func testMacro() {
assertMacroExpansion(
"""
@demonstration()
class TestClass {
}
""",
expandedSource: """
class TestClass {
}
extension TestClass : DemonstrationProtocol {}
""",
macros: testMacros
)
}
There is an error when I run the test case:
error: -[WWDC23Tests.WWDC23Tests testMacro] : failed - Actual output (+) differed from expected output (-):
class TestClass {
}
–extension TestClass : DemonstrationProtocol {}
But it runs fine when I execute it in the code.
It seems that the macro is missing the last line when it expands in the test.
Steps to Reproduce
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working