-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up dynamic member lookup key path sendability (#209)
* Clean up dynamic member lookup key path sendability Dynamic member lookup does not currently support sendable key paths, and we've had commented-out code as a result, but let's clean it up in favor of solutions employed in our other repos. * Update KeyPath+Sendable.swift * Update KeyPath+Sendable.swift * fix * fix
- Loading branch information
1 parent
1c26db4
commit f405870
Showing
4 changed files
with
36 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#if compiler(>=6) | ||
public typealias _SendableKeyPath<Root, Value> = any Sendable & KeyPath<Root, Value> | ||
#else | ||
public typealias _SendableKeyPath<Root, Value> = KeyPath<Root, Value> | ||
#endif | ||
|
||
// NB: Dynamic member lookup does not currently support sendable key paths and even breaks | ||
// autocomplete. | ||
// | ||
// * https://github.com/swiftlang/swift/issues/77035 | ||
// * https://github.com/swiftlang/swift/issues/77105 | ||
extension _AppendKeyPath { | ||
@_transparent | ||
package func unsafeSendable<Root, Value>() -> _SendableKeyPath<Root, Value> | ||
where Self == KeyPath<Root, Value> { | ||
#if compiler(>=6) | ||
unsafeBitCast(self, to: _SendableKeyPath<Root, Value>.self) | ||
#else | ||
self | ||
#endif | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters