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

Replace #fileID, #filePath, #line, and #column with a single macro. #304

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented Mar 19, 2024

We have a bunch of functions that take separate, defaulted arguments for file ID, column, etc. We'd like to normalize these functions to always take a single SourceLocation instance, but until now there hasn't been a way to express such a thing as a default argument without capturing the wrong source location.

This PR takes advantage of SE-0422 to create a new #here macro that does what we want here. (We can't use #sourceLocation because the language already reserves that macro name for an unrelated use.)

Because this is a new Swift 6 feature, we cannot rely on it until we drop our remaining Swift 5.10 support. Adding #if compiler(>=5.11) would require extensive changes and code duplication.

Resolves rdar://121883259.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

@grynspan grynspan added enhancement New feature or request public-api Affects public API swift-6 Swift 6 issues (not affecting Swift 5.x) labels Mar 19, 2024
@grynspan grynspan self-assigned this Mar 19, 2024
…macro.

We have a bunch of functions that take separate, defaulted arguments for file
ID, column, etc. We'd like to normalize these functions to always take a single
`SourceLocation` instance, but until now there hasn't been a way to express such
a thing as a default argument without capturing the wrong source location.

This PR takes advantage of [SE-0422](https://github.com/apple/swift-evolution/blob/main/proposals/0422-caller-side-default-argument-macro-expression.md)
to create a new `#here` macro that does what we want here. (We can't use
`#sourceLocation` because the language already reserves that macro name for an
unrelated use.)

Because this is a new Swift 6 feature, we cannot rely on it until we drop our
remaining Swift 5.10 support. Adding `#if compiler(>=5.11)` would require
extensive changes and code duplication.
@grynspan grynspan force-pushed the jgrynspan/replace-source-location-arguments-with-one-macro branch from e39dc93 to 9c1aca1 Compare April 9, 2024 14:30
@grynspan
Copy link
Contributor Author

grynspan commented Apr 9, 2024

@swift-ci please test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request public-api Affects public API swift-6 Swift 6 issues (not affecting Swift 5.x)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant