From 081928c84df83549bd5a04642ed00ec758e34521 Mon Sep 17 00:00:00 2001 From: sanghun0724 Date: Thu, 4 Jan 2024 18:57:48 +0900 Subject: [PATCH 1/2] Remove unused additional nil coalescing --- Sources/NeedleFoundation/Component.swift | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/Sources/NeedleFoundation/Component.swift b/Sources/NeedleFoundation/Component.swift index 075fe2a..757daf6 100644 --- a/Sources/NeedleFoundation/Component.swift +++ b/Sources/NeedleFoundation/Component.swift @@ -139,12 +139,7 @@ open class Component: Scope { sharedInstanceLock.unlock() } - // Additional nil coalescing is needed to mitigate a Swift bug appearing - // in Xcode 10. see https://bugs.swift.org/browse/SR-8704. Without this - // measure, calling `shared` from a function that returns an optional type - // will always pass the check below and return nil if the instance is not - // initialized. - if let instance = (sharedInstances[__function] as? T?) ?? nil { + if let instance = (sharedInstances[__function] as? T) { return instance } let instance = factory() @@ -248,12 +243,7 @@ open class Component: Scope { sharedInstanceLock.unlock() } - // Additional nil coalescing is needed to mitigate a Swift bug appearing - // in Xcode 10. see https://bugs.swift.org/browse/SR-8704. Without this - // measure, calling `shared` from a function that returns an optional type - // will always pass the check below and return nil if the instance is not - // initialized. - if let instance = (sharedInstances[__function] as? T?) ?? nil { + if let instance = (sharedInstances[__function] as? T) { return instance } let instance = factory() From 6f5b4a088c6795e409ac3f3e35edbb2805724678 Mon Sep 17 00:00:00 2001 From: sanghun0724 Date: Sun, 18 Aug 2024 12:47:47 +0900 Subject: [PATCH 2/2] Fix minor typo in comments --- .../Pluginized/PluginizedDependencyGraphExporter.swift | 6 +++--- .../NeedleFramework/Parsing/Tasks/ASTProducerTask.swift | 2 +- Generator/Sources/NeedleFramework/Utilities/Constants.swift | 2 +- Sources/NeedleFoundation/Bootstrap.swift | 2 +- Sources/NeedleFoundation/Component.swift | 6 +++--- .../Internal/DependencyProviderRegistry.swift | 2 +- .../Internal/PluginExtensionProviderRegistry.swift | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Generator/Sources/NeedleFramework/Generating/Pluginized/PluginizedDependencyGraphExporter.swift b/Generator/Sources/NeedleFramework/Generating/Pluginized/PluginizedDependencyGraphExporter.swift index 104c8ba..876b740 100644 --- a/Generator/Sources/NeedleFramework/Generating/Pluginized/PluginizedDependencyGraphExporter.swift +++ b/Generator/Sources/NeedleFramework/Generating/Pluginized/PluginizedDependencyGraphExporter.swift @@ -19,7 +19,7 @@ import Foundation import SourceParsingFramework /// The generation phase entry class that executes tasks to process dependency -/// graph components, inlcuding pluginized and non-core ones, into necessary +/// graph components, including pluginized and non-core ones, into necessary /// dependency providers and their registrations, then exports the contents to /// the destination path. class PluginizedDependencyGraphExporter { @@ -28,10 +28,10 @@ class PluginizedDependencyGraphExporter { /// code for the given components and pluginized components, and export /// the source code to the given destination path. /// - /// - parameter components: Array of Components to generate dependnecy + /// - parameter components: Array of Components to generate dependency /// providers for /// - parameter pluginizedComponents: Array of pluginized components to - /// generate plugin extensions and dependnecy providers for. + /// generate plugin extensions and dependency providers for. /// - parameter imports: The import statements. /// - parameter path: Path to file where we want the results written to. /// - parameter executor: The executor to use for concurrent computation of diff --git a/Generator/Sources/NeedleFramework/Parsing/Tasks/ASTProducerTask.swift b/Generator/Sources/NeedleFramework/Parsing/Tasks/ASTProducerTask.swift index e4b93b5..e67a437 100644 --- a/Generator/Sources/NeedleFramework/Parsing/Tasks/ASTProducerTask.swift +++ b/Generator/Sources/NeedleFramework/Parsing/Tasks/ASTProducerTask.swift @@ -24,7 +24,7 @@ import SwiftSyntax #endif /// A task that parses a Swift source content and produces Swift AST that -/// can then be parsed into the dependnecy graph. +/// can then be parsed into the dependency graph. class ASTProducerTask: AbstractTask { /// Initializer. diff --git a/Generator/Sources/NeedleFramework/Utilities/Constants.swift b/Generator/Sources/NeedleFramework/Utilities/Constants.swift index 77fcc76..f2613f8 100644 --- a/Generator/Sources/NeedleFramework/Utilities/Constants.swift +++ b/Generator/Sources/NeedleFramework/Utilities/Constants.swift @@ -26,5 +26,5 @@ let bootstrapComponentName = "BootstrapComponent" /// The name of the protocol that all Dependency protocols inherit from. let dependencyProtocolName = "Dependency" -/// The name fo the class that all Component classes inherit from +/// The name of the class that all Component classes inherit from let componentClassName = "Component" diff --git a/Sources/NeedleFoundation/Bootstrap.swift b/Sources/NeedleFoundation/Bootstrap.swift index cdf50a1..851f2bf 100644 --- a/Sources/NeedleFoundation/Bootstrap.swift +++ b/Sources/NeedleFoundation/Bootstrap.swift @@ -17,7 +17,7 @@ import Foundation /// An empty protocol that can be used for any components that require no -/// dependencies. This can be used as the dependnecy protocol of the root +/// dependencies. This can be used as the dependency protocol of the root /// component of a dependency graph. public protocol EmptyDependency: AnyObject {} diff --git a/Sources/NeedleFoundation/Component.swift b/Sources/NeedleFoundation/Component.swift index 757daf6..bc2e9fa 100644 --- a/Sources/NeedleFoundation/Component.swift +++ b/Sources/NeedleFoundation/Component.swift @@ -30,7 +30,7 @@ public protocol Registration { /// directly. /// @CreateMock public protocol Scope: AnyObject { - /// The path to reach this component on the dependnecy graph. + /// The path to reach this component on the dependency graph. var path: [String] { get } /// The parent of this component. @@ -83,7 +83,7 @@ open class Component: Scope { /// The parent of this component. public let parent: Scope - /// The path to reach this scope on the dependnecy graph. + /// The path to reach this scope on the dependency graph. // Use `lazy var` to avoid computing the path repeatedly. Internally, // this is always accessed with the `__DependencyProviderRegistry`'s lock // acquired. @@ -202,7 +202,7 @@ open class Component: Scope { /// The parent of this component. public let parent: Scope - /// The path to reach this scope on the dependnecy graph. + /// The path to reach this scope on the dependency graph. // Use `lazy var` to avoid computing the path repeatedly. Internally, // this is always accessed with the `__DependencyProviderRegistry`'s lock // acquired. diff --git a/Sources/NeedleFoundation/Internal/DependencyProviderRegistry.swift b/Sources/NeedleFoundation/Internal/DependencyProviderRegistry.swift index c5d8ff8..e1c039d 100644 --- a/Sources/NeedleFoundation/Internal/DependencyProviderRegistry.swift +++ b/Sources/NeedleFoundation/Internal/DependencyProviderRegistry.swift @@ -25,7 +25,7 @@ import Foundation // Once that happens, we can declare an `open createDependencyProvider` // method in the base component class. Generate extensions to all the // component subclasses that override the method to instantiate the -// dependnecy providers. +// dependency providers. public class __DependencyProviderRegistry { /// The singleton instance. diff --git a/Sources/NeedleFoundation/Pluginized/Internal/PluginExtensionProviderRegistry.swift b/Sources/NeedleFoundation/Pluginized/Internal/PluginExtensionProviderRegistry.swift index 2d85c93..bbffd48 100644 --- a/Sources/NeedleFoundation/Pluginized/Internal/PluginExtensionProviderRegistry.swift +++ b/Sources/NeedleFoundation/Pluginized/Internal/PluginExtensionProviderRegistry.swift @@ -24,7 +24,7 @@ import Foundation // Once that happens, we can declare an `open createPluginExtensionProvider` // method in the base pluginized component class. Generate extensions to // all the pluginized component subclasses that override the method to -// instantiate the dependnecy providers. +// instantiate the dependency providers. public class __PluginExtensionProviderRegistry { /// The singleton instance.