-
Notifications
You must be signed in to change notification settings - Fork 470
[Macros] Copy attrs/modifiers on MacroExpansionDecl to expanded decls #1666
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] Copy attrs/modifiers on MacroExpansionDecl to expanded decls #1666
Conversation
|
@swift-ci Please test |
| Specifiers.swift | ||
| Statements.swift | ||
| StringLiterals.swift | ||
| StringLiteralRepresentedLiteralValue.swift |
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.
Oh this is now unrelated to this PR. I wanted to use this feature (representedLiteralValue ) in swift repo test cases, but ended up with not using it because the compiler doesn't support @freestanding(declaration, names: arbitrary) macros.
But this was missing anyway.
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.
Thanks for noticing and fixing 🙏🏽
CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxTraitsFile.swift
Outdated
Show resolved
Hide resolved
| Specifiers.swift | ||
| Statements.swift | ||
| StringLiterals.swift | ||
| StringLiteralRepresentedLiteralValue.swift |
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.
Thanks for noticing and fixing 🙏🏽
| } | ||
|
|
||
| func testDeclsFromStringLiterals() { | ||
| assertMacroExpansion( |
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.
As with my comment in your other PR, I would really prefer this to be three different assertMacroExpansion calls, each only having a single #decl macro expansion. It just makes debugging so much easier if the test case fails.
Test 1
struct S {
public #decls(
"""
static func foo() {
print("value") }
""",
"struct Inner {\n\n}"
)
}Test 2
struct S {
@attr static #decls("var value1 = 1", "typealias A = B")
}Test 3
@attribute
@otherAttribute(x: 1) #decls("@moreAttibute var global = 42")As per the SE-0397 amendment, copy attributes and modifiers on MacroExpansionDecl to the expanded declarations.
06e6de2 to
d7d7a09
Compare
|
@swift-ci Please test |
|
@swift-ci Please test Windows |
As per the SE-0397 amendment, copy attributes and modifiers on
MacroExpansionDeclto the expanded declarations.Preparation:
AttributedSyntaxtoWithAttributesSyntax.AttributedSyntaxas a typealias toWithAttributeSyntaxWithModifiersSyntaxinit(_: [Element])toSyntaxCollection's requirements