Slim down DI bootstrap/dispatcher doc comments

This commit is contained in:
Wavesonics 2026-07-15 15:53:12 -07:00
parent 6f3051fa8d
commit ded3dcd504
3 changed files with 9 additions and 33 deletions

View file

@ -6,21 +6,12 @@ import org.koin.dsl.module
import kotlin.coroutines.CoroutineContext
/**
* Builds the qualified [CoroutineContext] dispatcher definitions in a module that does
* NOT carry the Koin compiler plugin.
*
* Under `compileSafety = true` the plugin emits a synthetic `dsl_single` hint for every
* definition in a plugin-processed `module { }`, encoding the `named()` qualifier as a
* value-parameter NAME. Kotlin/Native's `IdSignature` ignores parameter names, so our
* three same-type qualified dispatchers (main/default/io — all `CoroutineContext`)
* collapse to one signature and fail klib serialization. Keeping these three definitions
* out of the plugin's reach (here, in the plugin-less `:base`) sidesteps the clash while
* leaving the rest of the graph fully validated. The dispatchers are only ever consumed
* via runtime `inject(named(...))`, never constructor auto-wiring, so nothing the plugin
* validates depends on them.
*
* Qualifier names are passed in so the `DISPATCHER_*` constants can stay in `:common`
* alongside their consumers.
* The three same-type qualified [CoroutineContext] dispatchers live here, in the
* plugin-less `:base`, rather than in a Koin-compiler-plugin module. Under
* `compileSafety = true` the plugin encodes each `named()` qualifier as a parameter NAME,
* which Kotlin/Native's `IdSignature` ignores — so same-type qualified definitions clash
* during klib serialization. Qualifier names are passed in so the `DISPATCHER_*` constants
* can stay in `:common` with their consumers.
*/
fun dispatcherModule(
mainQualifier: String,

View file

@ -5,12 +5,8 @@ import org.koin.core.context.startKoin
import org.koin.dsl.KoinAppDeclaration
/**
* Starts Koin from a module that does not carry the Koin compiler plugin.
*
* The plugin runs its full-graph (A3) safety pass wherever a [startKoin] call is
* compiled. Keeping that call here — outside the plugin — means a platform bootstrap
* (notably iOS, whose entry point lives in the plugin-processed common module) can
* start Koin without turning its own compilation into an A3 aggregator. This matches
* how the desktop and android app modules already sit outside the plugin.
* Starts Koin from the plugin-less `:base`. The Koin compiler plugin runs its full-graph
* (A3) safety pass wherever [startKoin] is compiled; keeping the call here stops iOS's
* bootstrap from becoming an A3 aggregator, matching the desktop/android app modules.
*/
fun bootstrapKoin(declaration: KoinAppDeclaration): KoinApplication = startKoin(declaration)

View file

@ -17,17 +17,6 @@ plugins {
group = "com.darkrockstudios.apps.hammer"
version = libs.versions.app.get()
// compileSafety validates the DI graph at compile time (missing definitions become
// compile errors). Passes on all targets: desktop, android, common metadata, and iOS.
//
// Kotlin/Native (iOS) can't host multiple same-type qualified definitions in a plugin-
// processed module: the generated `dsl_single` hint functions encode a definition's
// named() qualifier as a value-parameter NAME, and K/N's IdSignature ignores parameter
// names — so same-type qualified definitions collapse to one signature and fail klib
// serialization with an Ir SignatureClashDetector AssertionError. Our three main/default/io
// CoroutineContext dispatchers hit this, so they're defined in a plugin-less module in
// :base instead (see dispatcherModule); they're only consumed via runtime inject(named()),
// never auto-wiring, so nothing the plugin validates depends on them.
koinCompiler {
compileSafety = true
}