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

Scope generates compile time error in 1.4.0 #193

Open
HLCaptain opened this issue Dec 2, 2024 · 0 comments
Open

Scope generates compile time error in 1.4.0 #193

HLCaptain opened this issue Dec 2, 2024 · 0 comments

Comments

@HLCaptain
Copy link

Describe the bug
Scoped functions will not get properly generated in default module resulting in "Unresolved reference defineRepositoryA" error.

To Reproduce

Starting code:

@Scope(name = "MyRepositories")
@Scoped
class RepositoryA {
	//...
}

@Scope(name = "MyRepositories")
@Scoped
class RepositoryB {
	//...
}

@Scope(name = "MyRepositories")
@Scoped
class RepositoryC {
	//...
}

The generated _defaultModule file looks like this:

public val _defaultModule : Module get() = module {
	// .... other dependencies
	defineRepositoryA() // not defined
	defineRepositoryB() // not defined
	defineRepositoryC() // not defined
}

Expected behavior

It looks like that KSP does not generate the method implementations for scoped dependencies while the other dependencies (with Single and Factory annotations) get generated like:

@Definition("com.my.app")
public fun Module.defineWorkingNormalDependency()  : KoinDefinition<*> = factory() { _ -> com.my.app.WorkingNormalDependency() }

Correct behavior (1.3.1) generating Kotlin Koin default module code:

scope(org.koin.core.qualifier.StringQualifier("MyRepositories")) {
	scoped() { com.my.app.RepositoryA() }
	scoped() { com.my.app.RepositoryB() } 
	scoped() { com.my.app.RepositoryC() } 
}

I do not know the constraints of defining methods for each repository one-by-one, but it looks like that the Scoped dependencies are grouped in 1.3.1, while in 1.4.0, each dependency has its own defineDependency-like method, which may restrain from grouping them together correctly.

Koin project used and used version (please complete the following information):
io.insert-koin:koin-annotations-bom:1.4.0 and io.insert-koin:koin-annotations-bom:1.3.1

Additional moduleDefinition
None

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

No branches or pull requests

1 participant