-
Notifications
You must be signed in to change notification settings - Fork 439
[Macros] Implement expansion of conformance macros #1773
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
[Macros] Implement expansion of conformance macros #1773
Conversation
Somehow, we forgot to implement this here, even though the compiler has supported it for a long time. Fixes swiftlang#1742 / rdar://110418242.
@swift-ci please test |
extension \(raw: identifier): \(type) { } | ||
""" | ||
if let whereClause { | ||
ext = DeclSyntax((ext.as(ExtensionDeclSyntax.self))!.with(\.genericWhereClause, whereClause)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slightly nicer version in my opinion would be
ext = DeclSyntax((ext.as(ExtensionDeclSyntax.self))!.with(\.genericWhereClause, whereClause)) | |
ext = DeclSyntax((ext.cast(ExtensionDeclSyntax.self)).with(\.genericWhereClause, whereClause)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I've pulled this in!
// refer to conformance macros, expand them and return the resulting | ||
// set of extension declarations. | ||
private func expandConformances(of decl: DeclGroupSyntax) -> [DeclSyntax] { | ||
let identifier: String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not make identifier: Syntax
and then you don’t need to convert to strings or use the raw
interpolation below. Also identifier
isn’t correct because ext.extendedType
is not an identifier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point, I've updated this code.
@swift-ci please test |
@swift-ci please test Windows |
Somehow, we forgot to implement this here, even though the compiler has supported it for a long time.
Fixes #1742 / rdar://110418242.