Skip to content
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] allow forwarding generic arguments through macro declarations #71271

Merged
merged 2 commits into from
Feb 6, 2024

Conversation

ktoso
Copy link
Contributor

@ktoso ktoso commented Jan 31, 2024


Specifically, this pattern is necessary:

@freestanding(expression) macro checkGenericHashableCodable_root<A: Hashable, B: Codable>() = 
  #externalMacro(module: "MacroDefinition", type: "GenericToVoidMacro")
@freestanding(expression) macro checkGenericHashableCodable<A: Hashable, B: Codable>() = 
  #checkGenericHashableCodable_root<A, B>()

#checkGenericHashableCodable<String, Int>

it seems we never considered this requirement, so this adds the ability to "replace" the A and B inside the "outer" macro's expansion such that the "root" also gets to see String and Int, and not just A and B.

I'll need some help figuring out what can be changed as is in this PR, and what changes we need to stage in - so we don't get compat issues with swift syntax.

[macros] add more tests for generic argument forwarding in macro declarations
@ktoso
Copy link
Contributor Author

ktoso commented Feb 2, 2024

@swift-ci please smoke test

swiftlang/swift-syntax#2450

@ktoso
Copy link
Contributor Author

ktoso commented Feb 6, 2024

swiftlang/swift-syntax#2450

@swift-ci please smoke test

@ktoso
Copy link
Contributor Author

ktoso commented Feb 6, 2024

@swift-ci please smoke test

@ktoso ktoso enabled auto-merge (squash) February 6, 2024 11:54
@ktoso ktoso merged commit 5acd366 into swiftlang:main Feb 6, 2024
3 checks passed
@ktoso ktoso deleted the wip-macro-forward-generic-args branch February 6, 2024 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant