You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When applying an attached member macro to e.g. a variable, assertMacroExpansion will currently happily swallow the attribute. It should, however, emit an error that member macros can’t be applied to variables (specifically, if the declaration is not a DeclGroupSyntax). Ie. the following test case should emit an error.
func testMemberMacroOnVar(){structTestMacro:MemberMacro{staticfunc expansion(
of node:AttributeSyntax,
providingMembersOf declaration:someDeclGroupSyntax,
conformingTo protocols:[TypeSyntax],
in context:someMacroExpansionContext)throws->[DeclSyntax]{return[]}}assertMacroExpansion(""" @Test var x: Int""",
expandedSource:""" var x: Int""",
macros:["Test":TestMacro.self
])}