Skip to content

[Macros] Add notion of owning module and supplemental modules for macros #1071

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

Merged

Conversation

DougGregor
Copy link
Member

Macros are associated with a module, which is the module in which they would be defined if the macro could be defined within the language itself. We call this the owning module. It will need to be imported in any Swift source file that wants to use the macro. Introduce an "owningModule" requirement to the Macro protocol to describe this.

The signatures of macros can make use of types in the owning module, but might also require other modules (e.g., that the owning module depends on). Introduce a "supplementalSignatureModules" requirement to the Macro protocol, with a default implementation of [] since this is unlikely to be used often.

Both the owning and supplemental modules will be imported when processing the macro signature.

…ros.

Macros are associated with a module, which is the module in which they
would be defined if the macro could be defined within the language
itself. We call this the owning module. It will need to be imported in
any Swift source file that wants to use the macro. Introduce an
"owningModule" requirement to the Macro protocol to describe this.

The signatures of macros can make use of types in the owning module,
but might also require other modules (e.g., that the owning module
depends on). Introduce a "supplementalSignatureModules" requirement to
the Macro protocol, with a default implementation of `[]` since this
is unlikely to be used often.

Both the owning and supplemental modules will be imported when
processing the macro signature.
@DougGregor DougGregor requested a review from ahoppen as a code owner November 10, 2022 21:24
@DougGregor
Copy link
Member Author

@swift-ci please test

@DougGregor DougGregor merged commit 3b7d3ad into swiftlang:main Nov 11, 2022
@DougGregor DougGregor deleted the macros-owning-supplemental-modules branch November 11, 2022 04:42
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