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
I acknowledge that the following graph is not ideal, but I believe it should compile without the need for any workarounds.
@Scope
annotation class Singleton
@Singleton
@Inject
class Interceptor(val client1: Lazy<Client1>, val client2: Lazy<Client2>)
@Inject
class Client1(val interceptor: Interceptor)
@Inject
class Client2(val interceptor: Interceptor)
@Inject
class Repository(val client1: Client1, val client2: Client2)
@Singleton
@Component
interface MyComponent {
val repository: Repository
}
I was able to compile by declaring the Interceptor dependency within the component.
@Singleton
@Component
interface MyComponent {
val interceptor: Interceptor
val dep: Dependency
}
or by removing the @Singleton annotation from Interceptor.
The text was updated successfully, but these errors were encountered:
AdriaBosch
changed the title
The presence of two Lazy dependencies prevents it from compiling.
Build fails when declaring two Lazy dependencies.
Aug 17, 2024
Ok I think I tracked down the cause of the issue. The expression for a given type is cached so it doesn't have to be recalculated when used in different places. However, when there is a a cycle that caching includes the reference to the lateinit variable, but not the lateinit variable itself. So when it's reused that variable doesn't exist.
I acknowledge that the following graph is not ideal, but I believe it should compile without the need for any workarounds.
I was able to compile by declaring the Interceptor dependency within the component.
or by removing the
@Singleton
annotation fromInterceptor
.The text was updated successfully, but these errors were encountered: