InsertKoinIO / InsertKoinIO/koin-compiler-plugin
Auto-binding misses transitive interfaces, so getAll<Base>() cannot collect implementations
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 82
- Forks
- 15
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Description
Description
With Koin Compiler Plugin 1.1.0, auto-binding for an annotated class appears to inspect only its direct supertypes. Transitive interfaces are not included in the generated Koin definition.
This makes a normal extension-point collection fail: a class is assignable to Controller, but getAll<Controller>() returns no instance because Koin indexes the definition under the generated binding types.
Versions
- Kotlin: 2.4.10
- Koin: 4.2.1
- Koin Compiler Plugin: 1.1.0
- Target: JVM
Minimal reproduction
interface Controller
interface CrudController<E> : Controller
interface GraphController<E> : CrudController<E>
data class Node(val id: Long)
@Single
class NodeController : GraphController<Node>
The class is discovered through a @Module @ComponentScan module and assembled by a @KoinApplication.
Actual behavior
The generated cross-module definition hint is equivalent to:
definition_single(NodeController, GraphController)
The generated module registers the definition under NodeController and GraphController, but not under CrudController or Controller.
Consequently:
koin.getAll<Controller>() // empty
Expected behavior
Since NodeController is transitively assignable to Controller, automatic binding should include the relevant transitive interfaces, or the documentation should explicitly state that only direct supertypes are auto-bound.
The annotations documentation says that interface binding is automatic when a class implements an interface.
Workaround
Declare the collection type as a direct supertype:
@Single
class NodeController : GraphController<Node>, Controller
This causes the generated hint and module to include Controller.
Could the compiler plugin either walk the full supertype closure or document the direct-supertype limitation?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Kotlin reproduction using @Single, @Module, @ComponentScan, and @KoinApplication, then inspect the generated cross-module definition hint and module bindings. Verify how supertypes are collected and confirm that getAll() discovers NodeController through CrudController and GraphController, or document the direct-supertype limitation if that is the intended behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100