Skip to content

Conversation

@slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Jun 9, 2025

The problem is that macro expansion can trigger expression type checking, which performs arbitrary name lookups, which can then fail if not all extensions have been bound yet.

To maintain source compatibility, we attempt extension binding a second time if anything fails, this time allowing macro expansion.

Fixes rdar://149798059.

Macro expansion can call typeCheckExpr(), which performs qualified
lookups. So if we expand macros while binding extensions, these
qualified lookups can fail because they cannot find members of
extensions that have not been bound yet.

To fix this, try binding extensions without performing macro
expansion first. If any extensions remain at the end, we fall back
to the old behavior, and try to bind them again, this time
performing macro expansion.

Fixes rdar://149798059.
@slavapestov slavapestov force-pushed the bind-extensions-macro branch from f6b18eb to 63a5731 Compare June 12, 2025 00:07
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

Copy link
Contributor

@rjmccall rjmccall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@slavapestov slavapestov merged commit 72401ca into swiftlang:main Jun 12, 2025
5 of 7 checks passed
slavapestov added a commit that referenced this pull request Jun 23, 2025
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.

2 participants