Skip to content

Commit

Permalink
Fix AbstractRegistration placeholder bug
Browse files Browse the repository at this point in the history
Registered placeholders should match the service type and name of the AbstractRegistration, otherwise there are incorrect placeholders created.
  • Loading branch information
bradfol committed Nov 12, 2024
1 parent 98fa6a0 commit c307060
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Sources/Knit/Module/Container+AbstractRegistration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ extension Container {

/// Register that a service is expected to exist but no implementation is currently available
/// The concrete implementation must be registered or the dependency graph is considered invalid
/// We don't currently support abstract registrations with arguments
/// - NOTE: We don't currently support abstract registrations with arguments
public func registerAbstract<Service>(
_ serviceType: Service.Type,
name: String? = nil,
Expand Down Expand Up @@ -47,7 +47,7 @@ internal protocol AbstractRegistration {
var name: String? { get }
var key: RegistrationKey { get }

/// Register a placeholder registration to fill the unfullfilled abstract registration
/// Register a placeholder registration to fill the unfulfilled abstract registration
/// This placeholder cannot be resolved
func registerPlaceholder(
container: Container,
Expand Down Expand Up @@ -85,7 +85,7 @@ fileprivate struct RealAbstractRegistration<ServiceType>: AbstractRegistration {
dependencyTree: DependencyTree
) {
let message = errorFormatter.format(error: self.error, dependencyTree: dependencyTree)
container.register(ServiceType.self) { _ in
container.register(ServiceType.self, name: name) { _ in
fatalError("Attempt to resolve unfulfilled abstract registration.\n\(message)")
}
}
Expand Down

0 comments on commit c307060

Please sign in to comment.