Swift Testing includes a type, SourceLocation, that represents the precise location of something in a file (typically a .swift file). Various Swift Testing API takes an instance of this type in order to correctly attribute diagnostics and test issues that occur at test time.
Swift Testing currently provides a #_sourceLocation macro that expands, at compile time, to an expression that generates an instance of SourceLocation, similar to how #fileID, #line, etc. work. This macro, being underscored, is not formally supported, nor does it appear in Swift Testing's documentation.
I propose we introduce a non-underscored macro and formally support this pattern. For more details, see the full proposal here.
I assume the plan would be: for some time both #SourceLocation and #_sourceLocation exist side by side, where the latter is deprecated? And after some time #_sourceLocation gets removed?
Likely #_sourceLocation would stick around until a major language change (i.e. Swift 7) but otherwise yes, it'll just sit there as a compatibility name in perpetuity.
I can’t believe I’m actually typing this, but considering #_sourceLocation was never supported and going to the supported version is a search-replace. Maybe we can sunset it sooner than a new major version?
Having an evolvable, single value with all location info would be great, though I would hate to take the good #sourceLocation name for a macro that isn't generally available. Seems like we should just solve the #filePath issue first, then make it available from the standard library.
This is a decision ultimately for the Testing Workgroup and review community to make, but there's no cost to keeping the old name around, and we did tell folks "wink-wink-nudge-nudge, you can use this underscored name", so…
In a hypothetical future where this macro is in the stdlib, Swift Testing would presumably migrate over to that definition. If the macro cannot move to the stdlib (for whatever reason!), it's moot really.