Kotlin 2.3.20 / 2.4.0 compatibility — version-adapter layer + unified IR API migration#52
Merged
Merged
Conversation
….4.0 compatible) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… and 2.4.0 - koin-compiler-version-adapter: KotlinVersionAdapter interface, registry-based KotlinAdapterLoader (only the selected adapter is classloaded), maturity-aware KotlinReleaseVersion parser - per-version adapters compiled against their own kotlin-compiler artifact: kotlin-2.3.20 and kotlin-2.4.0 (FIR registration binary contract + IrAnnotation conversion) - adapters embedded into the published koin-compiler-plugin jar (single artifact) - unknown newer Kotlin: WARN + newest adapter; older than floor: clear error - playground-apps: app-dsl/app-annotations on Kotlin 2.4.0, new app-floor-2320 guard on 2.3.20 with -PkotlinVersion override Fixes #19
…ground apps follow
- getDeprecationsProvider's receiver was specialized in 2.4.0 (NoSuchMethodError in markAsDeprecatedHidden on multi-module builds): routed through new KotlinVersionAdapter.refreshDeprecations, implemented per version - tools/abi-check: hierarchy-aware bytecode reference scanner — verifies every compiler-API ref in the plugin's bytecode resolves against a target Kotlin version (catches binary breaks that source recompiles can't see). Plugin bytecode: 411/411 refs resolve on both 2.3.20 and 2.4.0 - verified: box tests green, app-dsl + app-annotations build on Kotlin 2.4.0
…th version warnings, doc version - setExtensionReceiverArgument: error instead of silent no-op when callee has no extension receiver (avoids silently dropping the argument) - KotlinAdapterLoader.current: emit selection warnings on stderr on the self-init path (registrar path already routes them to messageCollector) - playground README: Compiler Plugin 1.0.0 -> 1.0.1
This was referenced Jun 9, 2026
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.
Fixes #19
Closes InsertKoinIO/koin#2431 (duplicate of #19)
Addresses the failure family of #42 (binary breaks across Kotlin versions)
Problem
The plugin compiles against exactly one
kotlin-compilerversion and ships a single artifact, but FIR/IR plugin APIs are unstable across Kotlin minors. Two releases in a row broke users:ClassCastException: FirExtensionRegistrarAdapter$Companion cannot be cast to ProjectExtensionDescriptor— the FIR registration binary contract changedNoSuchMethodError: IrDeclarationOrigin$Companion.getIR_EXTERNAL_DECLARATION_STUB()— same class of break, opposite directionEvery new Kotlin minor was a potential hard crash, fixable only by re-releasing the whole plugin.
Solution — two prongs
1. Core migrated to the unified IR API (
a2f8622)All IR-phase code now uses
parameters/IrParameterKind/arguments/typeArguments(available since 2.3.20, the API Kotlin itself migrated to) instead of the removed-in-2.4.0valueParameters/putValueArgument/extensionReceiveraccessors. ~480 version-split call sites eliminated; the regular-index ↔indexInParametersmapping is centralized inir/IrArgumentMapping.kt. Behavior-identical: full box-test suite unchanged and green.2. Version-adapter layer for the irreconcilable rest (
a0c759f,0b25301)New
koin-compiler-version-adapter/module: a 3-memberKotlinVersionAdapterinterface — each member documents the exact incompatibility forcing it via@KotlinApiChange:registerCompilerExtensionssetAnnotationsIrAnnotationContainer.annotationsbecameList<IrAnnotation>refreshDeprecationsgetDeprecationsProviderreceiver specialized (NoSuchMethodError on multi-module builds)Per-version implementations (
kotlin-2.3.20/,kotlin-2.4.0/), each compiled against its ownkotlin-compiler, all embedded in the published jar — the artifact stays a single jar. At plugin load,KotlinAdapterLoaderpicks the adapter from a registry file (META-INF/koin/kotlin-version-adapters.properties); only the selected adapter is ever classloaded.Fallback policy:
STRONG_WARNING+ best-effort newest adapterTooling (
0b25301)tools/abi-check/— hierarchy-aware bytecode scanner verifying every compiler-API reference in the plugin's bytecode resolves against a target Kotlin version. Catches binary-only breaks (the #42/#19 class) before release instead of via user crash reports. Current state: 411/411 refs resolve on both 2.3.20 and 2.4.0.Verification
playground-apps/app-floor-2320(new minimal floor guard, 2.3.20 +-PkotlinVersion=2.4.0probe)playground-apps/app-dsl— Android, Kotlin 2.4.0playground-apps/app-annotations— Android, Kotlin 2.4.0 (FIR/annotations path)Before this branch, both Android playground apps reproduced the exact #19 ClassCastException on Kotlin 2.4.0.
Release notes (1.0.1)
supported-kotlin-versions.txt)app-floor-2320guards the floorSupporting a future Kotlin version
./tools/abi-check/check-kotlin-abi.sh <version>— if 411/411 resolve and the FIR layer behaves, no adapter needed (newest adapter is reused)kotlin-<version>/adapter module + a registry line +supported-kotlin-versions.txtentry🤖 Generated with Claude Code