I have read the following question: Purpose of proxyProvide in Dagger 2 generated code
However, the accepted answer there states that the purpose of this method is to make it accessible publicly:
The thing is, that provides method may not be accessible from the same package as your component, so we generate this "proxy" method which gives Dagger the right accessibility.
But if the @Provides
method is not static, the module instance is locally created and passed along with the argument
In the Component:
private Engine getEngine() {
return DieselEngineModule_ProvideEngineFactory.proxyProvideEngine(
dieselEngineModule, getDieselEngine());
}
In the Factory:
public static Engine proxyProvideEngine(DieselEngineModule instance, DieselEngine engine) {
return Preconditions.checkNotNull(
instance.provideEngine(engine), "Cannot return null from a non-@Nullable @Provides method");
}
Both arguments are available in the component directly, so the purpose can't be the access modifier.
Then what is the reason for this detour over the proxyProvides
method?