`LazyClassKey` doesn't work when providing a `Map<Class<*>, Provider<?>` with a scope
lwasyl opened this issue · 0 comments
lwasyl commented
The following doesn't compile with Dagger KSP 2.51:
package com.example
import dagger.Component
import dagger.Module
import dagger.Provides
import dagger.multibindings.IntoMap
import dagger.multibindings.LazyClassKey
import javax.inject.Inject
import javax.inject.Provider
import javax.inject.Qualifier
import javax.inject.Scope
@Component(modules = [TestModule::class])
@SomeScope
interface TestComponent {
fun f(): F
}
@Module
internal class TestModule {
@Provides
@IntoMap
@SomeQualifier
@LazyClassKey(String::class)
fun foo(): String = "foo"
@Provides
@IntoMap
@SomeQualifier
@LazyClassKey(TestModule::class)
fun bar(): String = "foo"
}
@SomeScope
class F @Inject constructor(
@SomeQualifier private val arg: @JvmSuppressWildcards Map<Class<*>, Provider<String>>,
)
@Qualifier
annotation class SomeQualifier
@Scope
annotation class SomeScope
with the following error:
build/generated/ksp/main/java/com/example/DaggerTestComponent.java:77: error: incompatible types: MapProviderFactory<String,String> cannot be converted to MapFactory<String,String>
this.someQualifierMapOfClassOfAndProviderOfStringProvider = LazyClassKeyMap.Factory.<String>of(MapProviderFactory.<String, String>builder(2).put(LazyClassKeyProvider.java_lang_String, fooProvider).put(LazyClassKeyProvider.com_example_TestModule, barProvider).build());
^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
The above works if one of the following changes are made:
@ClassKey
is used instead of@LazyClassKey
@SomeScope
is not used