My question is pretty simple and straightforward: What is the difference between the two annotations / examples:
Example one
@Singleton
class MySingletonClass() {}
@Module
@InstallIn(FragmentComponent::class)
abstract class MyFragmentModule {
@Provides
fun provideMySingletonClass() = MySingletonClass()
}
Eaxmple two
class MySingletonClass() {}
@Module
@InstallIn(FragmentComponent::class)
abstract class MyFragmentModule {
@Singleton
@Provides
fun provideMySingletonClass() = MySingletonClass()
}
The only difference I know is, that the second example gives me the following error:
error: [Dagger/IncompatiblyScopedBindings] FragmentC scoped with @dagger.hilt.android.scopes.FragmentScoped may not reference bindings with different scopes:
Does that mean, that the @Singleton annotation in example one is simply ignored?