Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Module @ComponentScan Not Detecting Super Classes #128

Open
hscissors opened this issue May 5, 2024 · 1 comment
Open

@Module @ComponentScan Not Detecting Super Classes #128

hscissors opened this issue May 5, 2024 · 1 comment

Comments

@hscissors
Copy link

In the same package and gradle module:

@Module
@ComponentScan
class Sources

and

@Single
open class Preferences(
    private val prefs: SharedPreferences //<-- injected from same module
) :
    SomePrefsInterface1,
    SomePrefsInterface2
 {
   [...]
}

This setup fails to generate the module for Sources. If I explicitly add a binds = [SomePrefsInterface1:class] to the Preferences class, it seems to work. However this is a regression from previous versions.

Expected behavior
@ComponentScan should automatically bind all super classes (and interfaces) without needing to declare an explicit binds.

Koin project used and used version (please complete the following information):

kotlin = "1.9.21"
ksp = "1.9.21-1.0.16"
koin-ksp-compiler = "1.3.1"
koin-annotations = "1.3.1"
koin-core = "3.5.6"
@hscissors hscissors changed the title @Module @ComponentScan Not Deteching all Super Classes @Module @ComponentScan Not Detecting Super Classes May 5, 2024
@arnaudgiuliani arnaudgiuliani added this to the 2.0 milestone Sep 17, 2024
@bogdanzurac
Copy link

If I may add, we've seen the same type of behaviour, but with nested super classes, such as:

interface A
open class B : A
class C : B

In order for C to be made available in all places where we need it either as an A or B subclass, we currently need to set:

@Single(binds = [A::class, B::class])
class C : B

We're using Koin Annotations v1.4.0 and Koin Android v3.5.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants