Repository navigation
Support Kotlin 2.4.20 - #100
Closed
jamesarich wants to merge 1 commit into
Closed
jamesarich wants to merge 1 commit into
jamesarich wants to merge 1 commit into
Conversation
Kotlin 2.4.20 removes or re-signs four compiler APIs the plugin core binds: getValueArgument(IrConstructorCall, Name), IrAnnotationImpl.setArgumentMapping, IrFactory.createSimpleFunction and FirResolvedQualifier.classId. The plugin core is compiled against the 2.3.20 floor, so these surface at runtime as IrGenerationExtensionException / NoSuchMethodError rather than at build time. Adds a kotlin-2.4.20 adapter module and moves the three version-split operations behind KotlinVersionAdapter. getValueArgument is replaced core-side by a name-based getRegularArgument built on regularParameters, which is stable across every supported line. abi-check reports 0 missing for the core on 2.3.20, 2.4.0, 2.4.10 and 2.4.20. Test suite green, no golden-file changes. Fixes InsertKoinIO#89
Closed
|
Anyone tell me when be ready? |
Closed
Author
|
Reopened as #102 against Rebased, and picked up one more call site: |
Member
|
I'm fixing it in another branch 👍 |
Author
No worries, as long as it's getting handled 😅 - appreciate y'all 💚 |
Member
|
Yes released in 1.2.1 👍 |
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.
Kotlin 2.4.20 (2026-09-07) removes or re-signs four compiler APIs the plugin core binds, so 1.1.0 fails on every target with
IrGenerationExtensionException/NoSuchMethodError. Fixes #89.The core compiles against the floor (
compileOnly(kotlin("compiler")), catalogkotlin = "2.3.20"), so all four are binary breaks: the source still compiles, and nothing shows up until a user runs 2.4.20. That is exactly whatKotlinVersionAdapteris for, so this PR uses it rather than working around it.What breaks
Measured with
tools/abi-check/check-kotlin-abi.shover the core's 416org.jetbrains.kotlinreferences. Baseline before this PR: 0 missing on 2.3.20 / 2.4.0 / 2.4.10, 4 missing on 2.4.20 — so 2.4.20 is the whole delta.IrUtilsKt.getValueArgument(IrConstructorCall, Name)IrAnnotationImpl.setArgumentMapping(Map)argumentMappingis now a read-onlyIrAnnotationArgsViewcomputed fromarguments+symbolIrFactory.createSimpleFunction(...)IrClassSymbolparameterFirResolvedQualifier.classIdsymbolrenamed toqualifierSymbolWhy the 1.1.1 warning change does not cover this
RELEASE_NOTES_1.1.1.mdrelaxes the "newer than tested" warning from patch to minor-line granularity, verified against 2.4.10, and its own process note says to run abi-check on each new patch before relying on that. 2.4.20 is the case where the assumption does not hold. Worse, without a registered adapter the relaxed warning would have suppressed the one diagnostic that points at the cause, which is what users on #89 are hitting.What changed
kotlin-2.4.20adapter module, registered inkotlin-version-adapters.propertiesandsupported-kotlin-versions.txt, embedded in the published jar like the existing two. Its source is identical to the 2.4.0 adapter; only the bytecode differs, which is the point.KotlinVersionAdaptermembers for the version-split operations:createSimpleFunction,setAnnotationArgumentMapping,classIdOf. Each carries a@KotlinApiChangedocumenting the incompatibility, per the "keep this interface minimal" rule.createSimpleFunctionexposes only the parameters that actually vary across the 12 call sites. Every site passes the same final / non-inline / non-expect / non-tailrec / non-operator / non-infix / non-external / no-container-source / not-fake-override shape, so those are fixed inside each adapter. Generated code is unchanged, which the golden files confirm.getValueArgument(Name)is replaced core-side by a name-basedgetRegularArgument(Name)inIrArgumentMapping.kt, next to the existing index-based one. No adapter member needed: it is built onregularParameters, which is stable across every supported line. This is the overload that file's own comment missed, because it survived 2.4.0 and 2.4.10.setAnnotationArgumentMappingis a no-op on 2.4.20 and documented as such: the mapping is derived from the positional arguments the caller already set. On 2.3.20 and 2.4.0 it sets the field, and errors rather than silently dropping the mapping if handed something that is not anIrAnnotationImpl.Verification
Guard 1, don't break the current API. No golden file changed.
git status koin-compiler-plugin/testDatais clean, including every*_missing_d001.errors.txt. The transformations emit identical IR.abi-check, all four supported versions. 0 missing for the core on 2.3.20, 2.4.0, 2.4.10 and 2.4.20. Each adapter module also resolves cleanly against its own target. For contrast, the 2.4.0 adapter carrying the new members resolves with 3 missing against 2.4.20, which is why the new module is required rather than optional.
Guard 2, tests. Full suite green: 372 tests, 38 classes, 0 failures. Compile-safety and diagnostics specifically:
JvmDiagnosticTestGenerated47,JvmErrorMessageTestGenerated$Diagnostics47,JvmBoxTestGenerated$Safety38,KoinDiagnosticTest21,CompileSafetyValidatorSentinelTest1, all 0 failures.Guard 2, KLIB targets.
test-appson Kotlin 2.4.20 against this build:compileKotlinJvm,compileKotlinJsandcompileKotlinWasmJsall green, andjvmTestpasses 33 tests.Real-world KMP graph. Also validated against Meshtastic-Android, a ~17k-file KMP app with 393 Koin annotation sites across 263 files and 17 modules:
kmpSmokeCompilegreen across JVM andiosSimulatorArm64(Kotlin/Native, so real KLIB codegen), thenallTestsgreen at 7598 tests, 0 failures. No adapter-fallback warning, so 2.4.20 selects its own adapter exactly.There is no box test for this, and I do not think one is possible: the failure only reproduces under a specific compiler version, and the box harness runs one.
check-kotlin-abi.shis the real regression test for this class of bug, which leads to the next point.Three things noticed while doing this
check-kotlin-abi.shis not in CI.supported-kotlin-versions.txtsays it "drives the CI matrix", butbuild.ymlandrelease.ymlreference no Kotlin version at all —build.ymlis a single./gradlew build. So nothing would have caught this before a release, and nothing will catch the next one. Happy to wire the script into a matrix job as a follow-up PR if you want it.koin-compiler-plugin/build/classes/kotlin/main, never the adapter modules, so a break in an adapter is invisible to it. Also worth a follow-up../gradlew :sample-app:jvmRunfrom CLAUDE.md's Build Commands does not work:mainClasspoints atexamples.annotations.AnnotationsConfigTestKtand there is nofun mainanywhere insample-app. Pre-existing and untouched here, flagging it per the surprise rule.