Skip to content

Conversation

@jmschonfeld
Copy link
Contributor

While testing out the new buildConfiguration property on the macro expansion context, I noticed that when my macro was expanding in unit tests the macro was not receiving the build configuration. The root cause was that BasicMacroExpansionContext did not implement var buildConfiguration directly and was instead picking up the default implementation which always returns nil. This change implements the property by returning the value from the shared state.

I couldn't find existing tests that exercise the build configuration as part of an expansion context, but if there's a good place to add a unit test let me know and I can try to add that.

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

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

Ah, thank you!

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

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

Thank you!

@ahoppen
Copy link
Member

ahoppen commented Nov 21, 2025

@swift-ci Please test Windows

@jmschonfeld jmschonfeld force-pushed the basicmacroexpansioncontext-buildconfig branch from b78b08b to 0b2429f Compare January 5, 2026 23:39
@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

@jmschonfeld jmschonfeld enabled auto-merge (squash) January 5, 2026 23:41
@DougGregor
Copy link
Member

Once this lands, we should also cherry-pick to the 6.3 branch.

@jmschonfeld jmschonfeld merged commit e8fc57e into swiftlang:main Jan 6, 2026
103 of 105 checks passed
jmschonfeld added a commit to jmschonfeld/swift-syntax that referenced this pull request Jan 6, 2026
* Implement BasicMacroExpansionContext.buildConfiguration

* Fix formatting
@jmschonfeld jmschonfeld deleted the basicmacroexpansioncontext-buildconfig branch January 6, 2026 21:44
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.

3 participants