Skip to content

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 #_sourceLocation macro (name pending API review) that does what we want here. We can't use the obvious #sourceLocation because the language already reserves that macro name for an unrelated use.

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 labels Mar 19, 2024
@grynspan grynspan self-assigned this Mar 19, 2024
@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

@grynspan grynspan changed the title Replace #fileID, #filePath, #line, and #column with a single macro. [6.0 required] Replace #fileID, #filePath, #line, and #column with a single macro. May 22, 2024
@grynspan grynspan force-pushed the jgrynspan/replace-source-location-arguments-with-one-macro branch from 9c1aca1 to b3c34c4 Compare May 22, 2024 20:28
@grynspan
Copy link
Contributor Author

@swift-ci please test

@grynspan
Copy link
Contributor Author

grynspan commented Jun 4, 2024

@swift-ci please test Windows

@grynspan grynspan force-pushed the jgrynspan/replace-source-location-arguments-with-one-macro branch from b3c34c4 to 880a5ae Compare June 12, 2024 13:20
@grynspan grynspan changed the title [6.0 required] Replace #fileID, #filePath, #line, and #column with a single macro. Replace #fileID, #filePath, #line, and #column with a single macro. Jun 12, 2024
@grynspan grynspan force-pushed the jgrynspan/replace-source-location-arguments-with-one-macro branch from 880a5ae to c2d1142 Compare June 12, 2024 16:08
…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 `#currentSourceLocation` macro that does what we want here. (We
can't use `#sourceLocation` because the language already reserves that macro
name for an unrelated use.)
@grynspan grynspan force-pushed the jgrynspan/replace-source-location-arguments-with-one-macro branch from c2d1142 to 95fa0b5 Compare June 12, 2024 16:24
@grynspan grynspan marked this pull request as ready for review June 12, 2024 16:24
@grynspan
Copy link
Contributor Author

@swift-ci please test

@grynspan grynspan requested a review from stmontgomery June 13, 2024 15:40
@grynspan
Copy link
Contributor Author

@swift-ci please test

@grynspan
Copy link
Contributor Author

@swift-ci please test Linux

@grynspan grynspan merged commit 375b4c2 into main Jun 13, 2024
@grynspan grynspan deleted the jgrynspan/replace-source-location-arguments-with-one-macro branch June 13, 2024 20:32
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants