Repository navigation
fix: publish IR-built hints into KLIBs on Native/wasm/JS (#105, #106, #113) - #129
Merged
Merged
Conversation
…113) KLIB metadata only serializes a plugin-registered declaration for a FirFile of the FIR output (strict since Kotlin 2.4.20, KT-79565; per-package before that). Hints built in IR lived in synthetic files, so on KLIB targets they were dropped: false KOIN-D002, and real errors (D001/D003/D006) silently lost. - FIR declares a private `koin_hints_anchor()` in a generated hints-package file (non-JVM, root session); every IR-built hint is parented to that file (ir/HintFiles.kt, shared by the five former synthetic-file sites). JVM unchanged. - KOIN-W008: a full-graph check skipped because a module's definitions are not visible is now reported, naming the module, instead of passing silently. - playground-apps/app-kmp-klib-hints: RED/GREEN matrix (verify.sh) and an every-hint-kind check against jvm (verify-wide.sh). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Compile safety reads cross-module hints (
org.koin.plugin.hints.*). Most are built in IR, in a synthetic file, and registered withregisterFunctionAsMetadataVisible.On KLIB targets (Native, wasm, JS), Kotlin only serializes such a declaration for a
FirFileof the FIR output:A synthetic file is never part of the FIR output, so these hints were dropped. As a result:
KOIN-D002on valid code;JVM was not affected.
Fix
KoinModuleFirGeneratordeclares a privatekoin_hints_anchor()in a generated hints-package file. That file is part of the FIR output.ir/HintFiles.kt(addHintFunctions) parents every hint built in IR to the anchor's file. The helper replaces the five copy-pasted synthetic-file blocks:componentscan_,componentscanfunc_,funcreqs_,annotationincludes_,dsl_,dslincludes_,injectedparams_,callsite, and the relays. On JVM nothing changes: the old synthetic files and goldens are kept.KOIN-W008. When a full-graph check is skipped because a module's definitions are not visible, the plugin now warns and names the module instead of passing silently.Proof
All runs below use playground
playground-apps/app-kmp-klib-hints, with plugin 1.2.1 as RED and this branch as GREEN.KOIN-D001verify-wide.sh: every IR hint kind crossed once, KLIB diagnostics vs jvmTire, D003AppOnly, D006Greeter)KOIN-W008names the modulejs()target, metadata compilation (independent review)app-annotations/app-dslcross_module_annotation_incomplete_fold_no_false_d001(silent → W008)wasmJs on Kotlin 2.3.20 fails on both versions with KT-82395, a known limitation of that Kotlin version, not of this change.
To rerun it yourself:
./verify.sh <version> 2.3.20 2.4.0 2.4.10 2.4.20./verify-wide.sh <version>Behavior changes (in
RELEASE_NOTES_1.2.2.md)KOIN-W008on every target, JVM included, for example for an empty@ComponentScanin a dependency. It fails builds that useallWarningsAsErrors.org.koin.plugin.hints/*entries once (apiDump). The anchor itself is private and is not in the ABI.Not covered yet
commonMain;commonMain;CompileSafetyValidatorstill skips silently when the whole graph has zero definitions (low risk, since that graph is genuinely empty).Fixes #105, fixes #106, fixes #113 (GitHub only auto-closes on merge into the default branch; close them manually when 1.2.2 ships).