Binds optional
See original GitHub issueHello. Thank you so much for developing/maintaining Dagger2. I have a problem with @BindsOptionalOf
. Here is a primitive example of code https://gist.github.com/dmitro-ivanov/e03493211ebf0151cfebc5a6062b0a83.
As I could see from the documentation it is legal to inject Optional<IRepository>
, but at compile-time, I have the issue
error: incompatible types: Optional<Object> cannot be converted to Optional<IRepository>
Because the generated method injectMainActivity
is using Optional.empty()
without explicit specifying type.
A workaround that helps is that inject-field should be Provider<Optional<IRepository>>
.
Am I doing something illegal? or it is a bug?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
BindsOptionalOf - Dagger
Annotates methods that declare bindings for Optional containers of values from bindings that may or may not be present in the component.
Read more >Optional Binding in Swift. Avoid those force unwraps - Medium
Optional Binding. Optionals are a basic feature of Swift, and allow values to take either a value of .some or .none.
Read more >Optional Binding In Swift - Dev Genius
So we have been talking about optional binding, so let us cover how this works and why it is essential. Optional binding is...
Read more >OptionalBinder (Guice 4.1 API) - Google
An API to bind optional values, optionally with a default value. OptionalBinder fulfills two roles: It allows a framework to define an injection...
Read more >How to add optional @Bindings to SwiftUI views - FIVE STARS
Making the binding state optional. With FSDisclosureGroup there's no way around it: it needs a Binding<Bool> state.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Not the Dagger version, the ‘java source version’ also known as ‘target version’.
In an Android project this is usually found in the
android
closure, like this:It can also be manually configured using the Kotlin plugin:
Also, what version of Kotlin are you using?
I did not specify
jvmTarget
. When I addedEverything works fine. There is no more problem. Thank you. Maybe it will be useful for someone.