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

@OptionalInject does not work with actual optional #44

Open
bgeerdes opened this issue Nov 23, 2020 · 0 comments
Open

@OptionalInject does not work with actual optional #44

bgeerdes opened this issue Nov 23, 2020 · 0 comments

Comments

@bgeerdes
Copy link

bgeerdes commented Nov 23, 2020

The @OptionalInject wrapper only works if one provides a non-optional component. If the component is optional, the @OptionalInject wrapped instance always ends up nil.

This appears to be because the component is registered using its optional type (e.g. Optional<ComponentF>) but then the resolve fails as it is looking for non-optional type (e.g. ComponentF).

This can be demonstrated in DIKitTests testOptionalInjection by making ComponentF's init optional.

optional_init

Doing this causes the test to fail.

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