Skip to content

Optional dependency can not be resolved. #3

@vinczebalazs

Description

@vinczebalazs

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions