From aa8f45ed2f5e310df859d8b1b47e198e8f1c5821 Mon Sep 17 00:00:00 2001 From: Nick Cipollo Date: Wed, 13 Dec 2023 17:12:40 -0500 Subject: [PATCH] Fixes #3 Cleanup types within ServiceDictionary --- .github/workflows/test.yml | 5 ++++- Sources/WhoopDIKit/ServiceDictionary.swift | 6 +++--- Sources/WhoopDIKit/WhoopDI.swift | 3 +-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d240357..9fc708d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,8 @@ name: "Test" -on: [push, pull_request] +on: + push: + branches: ["main", "release*"] + pull_request: jobs: test: diff --git a/Sources/WhoopDIKit/ServiceDictionary.swift b/Sources/WhoopDIKit/ServiceDictionary.swift index 9d55e67..6e7f864 100644 --- a/Sources/WhoopDIKit/ServiceDictionary.swift +++ b/Sources/WhoopDIKit/ServiceDictionary.swift @@ -1,11 +1,11 @@ public final class ServiceDictionary { - private var valuesByType: [AnyHashable: Value] + private var valuesByType: [ServiceKey: Value] convenience public init() { self.init(valuesByType: [:]) } - private init(valuesByType: [AnyHashable: Value]) { + private init(valuesByType: [ServiceKey: Value]) { self.valuesByType = valuesByType } @@ -27,7 +27,7 @@ public final class ServiceDictionary { } } - public func allKeys() -> Set { + public func allKeys() -> Set { Set(valuesByType.keys) } diff --git a/Sources/WhoopDIKit/WhoopDI.swift b/Sources/WhoopDIKit/WhoopDI.swift index d564b55..7a378a8 100644 --- a/Sources/WhoopDIKit/WhoopDI.swift +++ b/Sources/WhoopDIKit/WhoopDI.swift @@ -89,8 +89,7 @@ public final class WhoopDI: DependencyRegister { /// Used internally via the `WhoopDIValidator` to verify all definitions in the object graph have definitions for their sub-dependencies (i.e this verifies the object graph is complete). internal static func validate(paramsDict: ServiceDictionary, onFailure: (Error) -> Void) { - serviceDict.allKeys().forEach { key in - let serviceKey = key as! ServiceKey + serviceDict.allKeys().forEach { serviceKey in let definition = getDefinition(serviceKey) do { let _ = try definition?.get(params: paramsDict[serviceKey])