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

DaggerKSP - Multibindings fail when a typealias is in use #4413

Open
tinder-johnbuhanan2 opened this issue Aug 26, 2024 · 1 comment
Open

Comments

@tinder-johnbuhanan2
Copy link

tinder-johnbuhanan2 commented Aug 26, 2024

On 2.51.1, when we try switching to Dagger KSP, our compilation breaks with the following:

/../view/component/SomeView_MembersInjector.java:46: error: incompatible types: Map<SomeType1,CAP#1> cannot be converted to Map<SomeType1,SomeType2<?,?>>
    instance.viewBinderMap = viewBinderMap;
                             ^
  where CAP#1 is a fresh type-variable:
    CAP#1 extends SomeType2<?,?> from capture of ? extends SomeType2<?,?>
1 error

The offender looks like this:

internal typealias ViewBinder = SomeType2<*, *>

internal typealias ViewBinderMap =
    Map<@JvmSuppressWildcards SomeType1, @JvmSuppressWildcards ViewBinder>

@AndroidEntryPoint
internal class SomeView(context: Context, attributeSet: AttributeSet?) : RecyclerView(context, attributeSet) {

    @Inject
    lateinit var viewBinderMap: ViewBinderMap
...
}

If we take out the typealias then it starts working.

@AndroidEntryPoint
internal class SomeView(context: Context, attributeSet: AttributeSet?) : RecyclerView(context, attributeSet) {

    // Without typealiases, this is an eyesore.
    @Inject
    lateinit var viewBinderMap: Map<@JvmSuppressWildcards SomeType1, @JvmSuppressWildcards SomeType2<*, *>>
...
}
@kuanyingchou
Copy link
Collaborator

Hi, @tinder-johnbuhanan2 , somehow I couldn't reproduce it on my side. Is it possible to provide a minimal reproducible project?

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

4 participants
@kuanyingchou @tinder-johnbuhanan2 and others