DIKit
DIKit copied to clipboard
@OptionalInject does not work with actual optional
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.
Doing this causes the test to fail.