Skip to content

New koin compiler plugin Unrecognized @ScopeId #2

@limuyang2

Description

@limuyang2

Describe the bug
New koin compiler plugin Unrecognized @ScopeId,Unable to inject object.
is correct in KSP.

To Reproduce
Steps to reproduce the behavior:
None

Expected behavior
Inject object.

Koin module and version:
koin: 4.2.0-RC1
koin-plugin: 0.3.0

Snippet or Sample project to help reproduce

@Scope(MyType::class)
@Scoped
class Tnt

interface MyType

// Init Application
@KoinApplication(modules = [AppModule::class])
class MyApp

class App: Application() {

    override fun onCreate() {
        super.onCreate()

        startKoin<MyApp> {
            androidLogger()
            androidContext(this@App)
        }

        getKoin().createScope<MyType>(scopeId = "a")
    }
}


// This is Bug Class
@Factory
class Lex(
    @ScopeId(name = "a") val t: Tnt // Unable to inject object.
)

// output error
println("lex: " + getKoin().get<Lex>())

Error info:

Caused by: org.koin.core.error.NoDefinitionFoundException: No definition found for type 'com.demo.Tnt' on scope '['_root_']'. Check your Modules configuration and add missing type and/or qualifier!

The error message says it is in root, but a is defined in @ScopeId

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions