Skip to content

Commit f0c4867

Browse files
authored
Merge pull request #127 from unsignedapps/keith/fvsc-safety
Tighten safety on FlagValueSourceCoordinator
2 parents 7a55d35 + 8979373 commit f0c4867

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

Sources/Vexil/Pole.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ public final class FlagPole<RootGroup>: Sendable where RootGroup: FlagContainer
8787
///
8888
public static var defaultSources: [any FlagValueSource] {
8989
#if !os(Linux)
90-
[
91-
FlagValueSourceCoordinator(source: UserDefaults.standard),
92-
]
90+
#if swift(>=6)
91+
[ FlagValueSourceCoordinator(source: UserDefaults.standard) ]
92+
#else
93+
[ FlagValueSourceCoordinator(uncheckedSource: UserDefaults.standard) ]
94+
#endif
9395
#else
9496
[]
9597
#endif

Sources/Vexil/Sources/FlagValueSourceCoordinator.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,20 @@ public final class FlagValueSourceCoordinator<Source>: Sendable where Source: No
2727

2828
// MARK: - Initialisation
2929

30-
public init(source: Source) {
30+
/// Create a FlagValueSource from a NonSendableFlagValueSource. If `Source` is a reference type,
31+
/// you must not continue to access it (except via this coordinator) after passing it to this
32+
/// initializer.
33+
public init(uncheckedSource source: Source) {
3134
self.source = .init(uncheckedState: source)
3235
}
3336

37+
#if swift(>=6)
38+
/// Create a FlagValueSource from a NonSendableFlagValueSource.
39+
public init(source: sending Source) {
40+
self.source = .init(uncheckedState: source)
41+
}
42+
#endif
43+
3444
}
3545

3646

0 commit comments

Comments
 (0)