Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional dependency can not be resolved. #3

Open
vinczebalazs opened this issue May 10, 2022 · 0 comments
Open

Optional dependency can not be resolved. #3

vinczebalazs opened this issue May 10, 2022 · 0 comments

Comments

@vinczebalazs
Copy link

vinczebalazs commented May 10, 2022

When registering an optional property, it can not be resolved by the property wrapper even when it's available (not nil).

Example:

class Foo {
    
    @Inject var bar: Int?
    
}

container.register(Int?.self) { _ in
    return 42
}.inObjectScope(.container)

From the docs I assume this should be supported and I have also seen an init created for Optionals, however that init is not used. I am not sure I fully understand the rationale behind how this generic init (on line 28) is supposed to work, but I believe for optional properties to resolve properly, the wrappedValue should be of an optional type as well or the Wrapped type should be passed as an argument to the generic init method, otherwise it is not used anywhere in the method body.

Looking forward to your reply, thanks.

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

No branches or pull requests

1 participant