swift-testing icon indicating copy to clipboard operation
swift-testing copied to clipboard

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

Open grynspan opened this issue 1 year ago • 1 comments

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:

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

grynspan avatar Mar 19 '24 21:03 grynspan

@swift-ci please test

grynspan avatar Apr 09 '24 14:04 grynspan

@swift-ci please test

grynspan avatar May 22 '24 20:05 grynspan

@swift-ci please test Windows

grynspan avatar Jun 04 '24 18:06 grynspan

@swift-ci please test

grynspan avatar Jun 12 '24 16:06 grynspan

@swift-ci please test

grynspan avatar Jun 13 '24 15:06 grynspan

@swift-ci please test Linux

grynspan avatar Jun 13 '24 16:06 grynspan