diff --git a/Sources/Container.swift b/Sources/Container.swift index f6e44430..4bcfcc7c 100644 --- a/Sources/Container.swift +++ b/Sources/Container.swift @@ -414,6 +414,7 @@ extension Container: Resolver { return persistedInstance } entry.storage.setInstance(resolvedInstance as Any, inGraph: currentObjectGraph) + graphInstancesInFlight.append(entry) if let completed = entry.initCompleted as? (Resolver, Any) -> Void, let resolvedInstance = resolvedInstance as? Service { diff --git a/Tests/SwinjectTests/ContainerTests.swift b/Tests/SwinjectTests/ContainerTests.swift index c4aa2abf..8e166c96 100644 --- a/Tests/SwinjectTests/ContainerTests.swift +++ b/Tests/SwinjectTests/ContainerTests.swift @@ -87,7 +87,7 @@ class ContainerTests: XCTestCase { parent.register(Cat.self) { _ in Cat() } weak var weakCat = child.resolve(Cat.self) - XCTAssertNotNil(weakCat) + XCTAssertNil(weakCat) } #if !SWIFT_PACKAGE @@ -227,7 +227,7 @@ class ContainerTests: XCTestCase { .inObjectScope(.weak) weak var cat = container.resolve(Animal.self) as? Cat - XCTAssertNotNil(cat) + XCTAssertNil(cat) } // MARK: Init completed event