0026-TASK-LOCAL-TEST-TRAIT: TaskLocal test trait
- Proposal: ST-0026
- Authors: Brandon Williams, Stephen Celis
- Review Manager: Stuart Montgomery
- Status: Active Review (July 17...July 27, 2026)
- Implementation: swiftlang/swift-testing#1764
- Review: (pitch) (review)
Source compatibility
The proposed APIs are purely additive.
Alternatives considered
A few other spellings have been proposed:
$isEnabled.set(true).withValue(true, for: $isEnabled).binding($isEnabled, to: true)
We prefer the naming .taskLocal(::) because it unambiguously refers to task locals, and keeps the arguments in the same order as withValue.
We could also decide to not add the trait since technically it is possible to implement its functionality manually for each task local.
Future directions
If Swift macros gain the ability to see symbols defined by other macros, this proposed API would become usable in more contexts/situations.