You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 9, 2023. It is now read-only.
I am facing problems with kotlin generics that use in or out to specify generics. The case that I was trying to inject is the following:
@Binds
abstract fun bindAddEntryUseCase(
useCase: AddEntryUseCase
): UseCase<AddEntry, Result<Unit>>
@HiltViewModel
class AddViewModel @Inject constructor(
@AddUseCase private val useCase: UseCase<AddEntry, Result<Unit>>
) : ViewModel() { ... }
class AddEntryUseCase @Inject constructor() : UseCase<AddEntry, Result<Unit>> {
override suspend fun execute(params: AddEntry): Result<Unit> {
...
return Result.success(Unit)
}
}
Result signature is class Result<out T> and when I try to inject Hilt throws the below error:
@Binds methods' parameter type must be assignable to the return type
public abstract com.eeema.android.domain.usecase.UseCase<com.eeema.android.domain.model.AddEntry, kotlin.Result<kotlin.Unit>> bindAddEntryUseCase(@org.jetbrains.annotations.NotNull()
I don't know why is not possible to inject generics with in or out types. Version of Hilt: 2.43.2
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi,
I am facing problems with kotlin generics that use in or out to specify generics. The case that I was trying to inject is the following:
Result signature is class
Result<out T>
and when I try to inject Hilt throws the below error:I don't know why is not possible to inject generics with in or out types. Version of Hilt: 2.43.2
The text was updated successfully, but these errors were encountered: