I think generalizing conformance macros to extension macros is a good idea, but it should also be possible to attach attributes and modifiers to the extension. Attributes in particular are crucial for declaring conformances with partial availability, a feature ConformanceMacro
cannot currently support.
Better yet, the tuple should be replaced by a nominal type that would allow these kinds of changes in the future as new features are added to the language. The other expansion methods all return a complete syntax node per item, which means they effortlessly support future language features. But conformance/extension macros instead return a tuple of constituents of a syntax node; expanding that tuple will cause a source compatibility break. There are good reasons not to just return an ExtensionDeclSyntax
, but that means we need to think about other ways to provide the flexibility it needs.
(Alternatively, just pass a TypeSyntax
node to the expansion method and require it to return only ExtensionDeclSyntax
nodes using that exact type syntax.)