Skip to content

Teach the TypeRefinementContext not to skip declarations within macro expansions #77517

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
merged 1 commit into from
Nov 11, 2024

Conversation

DougGregor
Copy link
Member

The construction of type refinement contexts performs lazy expansion for the contents of macro expansions, so that TRC creation doesn't force all macros to be expanded. However, the logic that skips macro expansions would also skip some declarations produced within a macro expansion, even when building the TRC specifically for that macro expansion buffer. This manifest as missing some availability information within the TRC, rejecting some well-formed code.

Tune the logic for "don't visit macro expansions when building a TRC" to recognize when we're building a TRC for that macro expansion.

Fixes rdar://128400301.

… expansions

The construction of type refinement contexts performs lazy expansion
for the contents of macro expansions, so that TRC creation doesn't
force all macros to be expanded. However, the logic that skips macro
expansions would *also* skip some declarations produced within a macro
expansion, even when building the TRC specifically for that macro
expansion buffer. This manifest as missing some availability
information within the TRC, rejecting some well-formed code.

Tune the logic for "don't visit macro expansions when building a TRC"
to recognize when we're building a TRC for that macro expansion.

Fixes rdar://128400301.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor DougGregor merged commit f641890 into swiftlang:main Nov 11, 2024
3 checks passed
@DougGregor DougGregor deleted the rtc-macro-expansion branch November 11, 2024 00:44
Copy link
Contributor

@tshortli tshortli left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@@ -538,6 +538,69 @@ class TypeRefinementContextBuilder : private ASTWalker {
return MacroWalking::Arguments;
}

/// Check whether this declaration is in a source file buried within
/// a macro expansion of the
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like your thought wasn't finished here

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you, finished the thought in #77528

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