Skip to content

Conversation

skorulis-ap
Copy link
Collaborator

@skorulis-ap skorulis-ap commented Aug 25, 2025

This changes how Resolvers are created so rather than every container conforming to every Resolver, there are concrete instances of Resolvers allowing correct inheritance.

For some reason this really pushed the Swift compiler causing multiple crashes. The top level Resolver must remain as a protocol otherwise type equality checks cause the compiler to crash.

@skorulis-ap skorulis-ap force-pushed the skorulis/resolver-class branch 16 times, most recently from 49549d2 to cf40012 Compare August 26, 2025 10:11
@@ -58,18 +58,6 @@ public final class ScopedModuleAssembler<TargetResolver> {
behaviors: [Behavior] = [],
postAssemble: ((Container<TargetResolver>) -> Void)? = nil
) throws {
// For provided modules, fail early if they are scoped incorrectly
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't needed since the TargetResolver check is already done at compile time.

@skorulis-ap skorulis-ap marked this pull request as ready for review August 26, 2025 10:22
@skorulis-ap skorulis-ap force-pushed the skorulis/resolver-class branch 2 times, most recently from 90def33 to 6c38f05 Compare August 26, 2025 11:15
@skorulis-ap skorulis-ap requested a review from bradfol August 26, 2025 22:58
let resolver = r.resolve(Container<TargetResolver>.self)! as! TargetResolver
let resolver = r.resolve(Container<TargetResolver>.self)!.resolver
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I must have missed this one previously

public func unsafeResolver(file: StaticString, function: StaticString, line: UInt) -> Swinject.Resolver {
_unwrappedSwinjectContainer(file: file, function: function, line: line)
}
public let resolver: TargetResolver
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does keeping this property access mean all the existing Container.register methods remain the same?

@@ -40,9 +40,8 @@ public extension ModuleAssembly {
static var replaces: [any ModuleAssembly.Type] { [] }

static func scoped(_ dependencies: [any ModuleAssembly.Type]) -> [any ModuleAssembly.Type] {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove static func scoped( from the public protocol now? Seems like it is no longer the extension point

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved this into a private function. There's no need for it to be overridden anymore

@skorulis-ap skorulis-ap force-pushed the skorulis/resolver-class branch 2 times, most recently from 08993fc to e06231c Compare August 29, 2025 11:09
@skorulis-ap skorulis-ap force-pushed the skorulis/resolver-class branch 3 times, most recently from 28f6855 to 4c867ff Compare September 3, 2025 06:21
@skorulis-ap skorulis-ap force-pushed the skorulis/resolver-class branch from 4c867ff to f645ad9 Compare September 3, 2025 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants