8000 SyntaxProtocol.expand() does not expand conformance macros · Issue #1742 · swiftlang/swift-syntax · GitHub
[go: up one dir, main page]

Skip to content

SyntaxProtocol.expand() does not expand conformance macros #1742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tgoyne opened this issue Jun 7, 2023 · 1 comment · Fixed by #1773
Closed

SyntaxProtocol.expand() does not expand conformance macros #1742

tgoyne opened this issue Jun 7, 2023 · 1 comment · Fixed by #1773
Labels
bug Something isn't working

Comments

@tgoyne
Copy link
tgoyne commented Jun 7, 2023

Description

Conformance macros used in the input source are discarded without expansion. A basic example:

struct Conformance: ConformanceMacro {
    public static func expansion(
        of node: AttributeSyntax,
        providingConformancesOf declaration: some DeclGroupSyntax,
        in context: some MacroExpansionContext
    ) throws -> [(TypeSyntax, GenericWhereClauseSyntax?)] {
        fatalError()
    }
}
assertMacroExpansion("@Foo class Bar {}", expandedSource: "class Bar {\n}",
                     macros: ["Foo": Conformance.self])

This test passes despite the implementation being fatalError() due to expansion(of:performanceConformanceOf:in:) never being called. There appears to be two parallel implementations of macro expansion with ConformanceMacro only being supported in expandAttachedMacro(), which is not called by SyntaxProtocol.expand().

There may be other macro types not implemented as well; I did not try them all.

Steps to Reproduce

No response

@tgoyne tgoyne added the bug Something isn't working label Jun 7, 2023
@ahoppen
Copy link
Member
ahoppen commented Jun 7, 2023

Tracked in Apple’s issue tracker as rdar://110418242

DougGregor added a commit to DougGregor/swift-syntax that referenced this issue Jun 13, 2023
Somehow, we forgot to implement this here, even though the compiler has
supported it for a long time.

Fixes swiftlang#1742 / rdar://110418242.
DougGregor added a commit to DougGregor/swift-syntax that referenced this issue Jun 14, 2023
Somehow, we forgot to implement this here, even though the compiler has
supported it for a long time.

Fixes swiftlang#1742 / rdar://110418242.

(cherry picked from commit 318d6c7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0