question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AssistedInject crashes without message when using with class with generic parameter

See original GitHub issue

AssistedInject fails without explanation when I try to use it with various classes that use generics. The simplest case that fails for me with Dagger 2.24, AssistedInject 0.5.0 and Kotlin 1.3.50:

class AClass<A> @AssistedInject constructor(
    @Assisted dependency: String
) {

    @AssistedInject.Factory
    interface Factory {

        fun create(dependency: String): AClass<String>
    }
}

The only error that appears is the following:

error: cannot find symbol
@dagger.Module(includes = {AssistedInject_PresentationModule.class})
                           ^
  symbol: class AssistedInject_PresentationModule
FAILURE: Build failed with an exception.

This is just a simplified version of what I was trying to do initially, which also fails with no meaningful message:

abstract class Base<T>
class Wrapper<A, B>

class AClass<A, B> @AssistedInject constructor(
    @Assisted dependency: (A) -> B
) : Base<Wrapper<A, B>>() {

    @AssistedInject.Factory
    interface Factory {

        fun <A, B> create(dependency: (A) -> B): AClass<A, B>
    }
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
JakeWhartoncommented, Sep 4, 2019

Narrowed in on the cause. The fix isn’t so trivial though, but I’m working on it.

0reactions
lwasylcommented, Nov 27, 2019

Seems like this is closed by #125, but fyi the test you added in #123 wasn’t un-ignored and still fails. Not sure if it’s the test that’s incorrect or this was closed by mistake

Read more comments on GitHub >

github_iconTop Results From Across the Web

AssistedInject crashes without message when using with class ...
AssistedInject fails without explanation when I try to use it with various classes that use generics. The simplest case that fails for me ......
Read more >
Problem with generic return type in guice assisted inject factory
There are two issues with your code above. First, RealPayment implements Payment<SwissFrancs> , but PaymentFactory.create returns Payment<Currency> .
Read more >
Connecting The Dots: Dagger • ViewModel • Saved State
The generic parameter T serves as way to inform AssistedInject about what type of ViewModel it should generate.
Read more >
Use Hilt with other Jetpack libraries - Android Developers
Inject ViewModel objects with Hilt​​ Provide a ViewModel by annotating it with @HiltViewModel and using the @Inject annotation in the ViewModel ...
Read more >
How to Set up Dagger With ViewModel & Saved State Module
I'm not going to get deep into Dagger, so if you don't know the basics ... dynamic parameters? Crash! ...Or an improperly initialized...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found