Skip to content

Commit dbcd9d4

Browse files
authored
Don't include unavailable setter in Swift 5.9. (#64)
1 parent 94887a3 commit dbcd9d4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Sources/Sharing/Shared.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public struct Shared<Value> {
102102
/// }
103103
/// }
104104
/// ```
105+
#if compiler(>=6)
105106
public var wrappedValue: Value {
106107
get {
107108
@Dependency(\.snapshots) var snapshots
@@ -120,6 +121,16 @@ public struct Shared<Value> {
120121
withLock { $0 = newValue }
121122
}
122123
}
124+
#else
125+
public var wrappedValue: Value {
126+
@Dependency(\.snapshots) var snapshots
127+
if snapshots.isAsserting {
128+
return reference.snapshot ?? reference.wrappedValue
129+
} else {
130+
return reference.wrappedValue
131+
}
132+
}
133+
#endif
123134

124135
/// Perform an operation on shared state with isolated access to the underlying value.
125136
///

0 commit comments

Comments
 (0)