@@ -176,6 +176,15 @@ final class DependencyValuesTests: XCTestCase {
176176 XCTAssertEqual ( childDependencyLateBindingEscaped. fetch ( ) , 1_000 )
177177 }
178178 }
179+
180+ func testNestedDependencyIsOverridden( ) {
181+ DependencyValues . withValue ( \. nestedValue. value, 10 ) {
182+ @Dependency ( \. nestedValue) var nestedValue : NestedValue
183+ @Dependency ( \. nestedValue. value) var value : Int
184+ XCTAssertEqual ( nestedValue. value, 10 )
185+ XCTAssertEqual ( value, 10 )
186+ }
187+ }
179188}
180189
181190struct SomeDependency : TestDependencyKey {
@@ -198,6 +207,11 @@ struct ChildDependencyLateBinding: TestDependencyKey {
198207 }
199208 }
200209}
210+ struct NestedValue : TestDependencyKey {
211+ static var testValue : Self { . init( ) }
212+ var value : Int = 0
213+ }
214+
201215extension DependencyValues {
202216 var someDependency : SomeDependency {
203217 get { self [ SomeDependency . self] }
@@ -211,6 +225,10 @@ extension DependencyValues {
211225 get { self [ ChildDependencyLateBinding . self] }
212226 set { self [ ChildDependencyLateBinding . self] = newValue }
213227 }
228+ var nestedValue : NestedValue {
229+ get { self [ NestedValue . self] }
230+ set { self [ NestedValue . self] = newValue }
231+ }
214232}
215233
216234private let someDate = Date ( timeIntervalSince1970: 1_234_567_890 )
0 commit comments