Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions RELEASE_NOTES_1.1.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,36 @@ itself is unchanged.
**Process note:** this trusts that a new patch within a supported line stays compatible. Verify
new patches with `tools/abi-check/check-kotlin-abi.sh <version>` before relying on it — see
CLAUDE.md's version-gate policy.

## Added — Kotlin 2.4.20 support (`koin-compiler-version-adapter:kotlin-2.4.20`)

**Why.** The minor-line warning relaxation above was verified against Kotlin 2.4.10 only, and its
own process note says to run `tools/abi-check/check-kotlin-abi.sh` on each new patch before
relying on it. Running it against 2.4.20 finds **four binary breaks** in the plugin core, so
2.4.20 does *not* stay compatible within the 2.4 line, and without a registered adapter the
relaxed warning would have suppressed the only diagnostic pointing at the cause. Reported as #89.

**Breaks found** (plugin core, 416 compiler-API refs; 0 missing on 2.3.20/2.4.0/2.4.10):

- `IrUtilsKt.getValueArgument(IrConstructorCall, Name)` — removed. 9 call sites.
- `IrAnnotationImpl.setArgumentMapping(Map)` — removed; `argumentMapping` is now a read-only
`IrAnnotationArgsView` computed from `arguments` + `symbol`.
- `IrFactory.createSimpleFunction(...)` — gained a trailing `IrClassSymbol` parameter. 12 call sites.
- `FirResolvedQualifier.classId` — removed; `symbol` renamed to `qualifierSymbol`.

**What changed:**

- New `kotlin-2.4.20` adapter module, registered in `kotlin-version-adapters.properties` and
`supported-kotlin-versions.txt`, embedded in the published jar like the existing two.
- Three new `KotlinVersionAdapter` members for the version-split operations —
`createSimpleFunction`, `setAnnotationArgumentMapping`, `classIdOf` — each annotated with
`@KotlinApiChange`. The `createSimpleFunction` member exposes only the parameters that actually
vary across call sites; the invariant flags are fixed in each adapter, so generated code is
unchanged.
- `getValueArgument(Name)` replaced by a name-based `getRegularArgument(Name)` in
`IrArgumentMapping.kt`, alongside the existing index-based one. No adapter needed: it is built
on `regularParameters`, which is stable across every supported line.

**Verification.** `check-kotlin-abi.sh` reports 0 missing for the plugin core on **2.3.20, 2.4.0,
2.4.10 and 2.4.20**, and each adapter module resolves cleanly against its own target. Full test
suite green (372 tests) with **no golden-file changes** — the transformations emit identical IR.
2 changes: 2 additions & 0 deletions koin-compiler-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ dependencies {
embeddedAdapters(project(":koin-compiler-version-adapter"))
embeddedAdapters(project(":koin-compiler-version-adapter:kotlin-2.3.20"))
embeddedAdapters(project(":koin-compiler-version-adapter:kotlin-2.4.0"))
embeddedAdapters(project(":koin-compiler-version-adapter:kotlin-2.4.20"))

// Tests run the plugin in-process — adapter classes must be on the test runtime classpath.
testRuntimeOnly(project(":koin-compiler-version-adapter"))
testRuntimeOnly(project(":koin-compiler-version-adapter:kotlin-2.3.20"))
testRuntimeOnly(project(":koin-compiler-version-adapter:kotlin-2.4.0"))
testRuntimeOnly(project(":koin-compiler-version-adapter:kotlin-2.4.20"))

testFixturesApi(kotlin("test-junit5"))
testFixturesApi(kotlin("compiler-internal-test-framework"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ class KoinModuleFirGenerator(session: FirSession) : FirDeclarationGenerationExte
extractClassIdFromExpression(arg)
}
is org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier -> {
expression.classId
KotlinAdapterLoader.current.classIdOf(expression)
}
else -> null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import org.koin.compiler.plugin.ProvidedTypeRegistry
import org.koin.compiler.plugin.fir.KoinModuleFirGenerator
import kotlin.io.path.Path
import kotlin.io.path.absolutePathString
import org.koin.compiler.adapter.KotlinAdapterLoader

@OptIn(DeprecatedForRemovalCompilerApi::class)
class CallSiteValidator(private val context: IrPluginContext) {
Expand Down Expand Up @@ -215,25 +216,17 @@ class CallSiteValidator(private val context: IrPluginContext) {
val targetClass = callSite.targetClass

// Build the IR function
val function = context.irFactory.createSimpleFunction(
startOffset = UNDEFINED_OFFSET,
endOffset = UNDEFINED_OFFSET,
origin = IrDeclarationOrigin.DEFINED,
name = hintName,
visibility = DescriptorVisibilities.PUBLIC,
isInline = false,
isExpect = false,
returnType = context.irBuiltIns.unitType,
modality = Modality.FINAL,
symbol = IrSimpleFunctionSymbolImpl(),
isTailrec = false,
isSuspend = false,
isOperator = false,
isInfix = false,
isExternal = false,
containerSource = null,
isFakeOverride = false
)
val function = KotlinAdapterLoader.current.createSimpleFunction(
factory = context.irFactory,
startOffset = UNDEFINED_OFFSET,
endOffset = UNDEFINED_OFFSET,
origin = IrDeclarationOrigin.DEFINED,
name = hintName,
visibility = DescriptorVisibilities.PUBLIC,
returnType = context.irBuiltIns.unitType,
isSuspend = false,
symbol = IrSimpleFunctionSymbolImpl(),
)

// Add parameter with the required type (erased to raw form for generics — see #18)
val requiredParam = context.irFactory.createValueParameter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,14 @@ private fun buildDeprecatedHiddenAnnotation(context: IrPluginContext): IrConstru
// arg 2: level (DeprecationLevel.HIDDEN)
putRegularArgument(2, levelExpr)

// Also set argument mapping (used by IR annotation processing and metadata serialization)
argumentMapping = mapOf(
Name.identifier("message") to messageExpr,
Name.identifier("level") to levelExpr
// Also record the argument mapping (used by IR annotation processing and metadata
// serialization). Kotlin 2.4.20 derives it from `arguments`; older lines need it set.
KotlinAdapterLoader.current.setAnnotationArgumentMapping(
this,
mapOf(
Name.identifier("message") to messageExpr,
Name.identifier("level") to levelExpr,
),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import org.koin.compiler.plugin.KoinPluginLogger
import org.koin.compiler.plugin.fir.KoinModuleFirGenerator
import kotlin.io.path.Path
import kotlin.io.path.absolutePathString
import org.koin.compiler.adapter.KotlinAdapterLoader

@OptIn(DeprecatedForRemovalCompilerApi::class)
class DslHintGenerator(
Expand Down Expand Up @@ -199,25 +200,17 @@ class DslHintGenerator(
val hintName = KoinModuleFirGenerator.dslDefinitionHintFunctionName(defTypeString)

// Build the IR function
val function = context.irFactory.createSimpleFunction(
startOffset = UNDEFINED_OFFSET,
endOffset = UNDEFINED_OFFSET,
origin = IrDeclarationOrigin.DEFINED,
name = hintName,
visibility = DescriptorVisibilities.PUBLIC,
isInline = false,
isExpect = false,
returnType = context.irBuiltIns.unitType,
modality = Modality.FINAL,
symbol = IrSimpleFunctionSymbolImpl(),
isTailrec = false,
isSuspend = false,
isOperator = false,
isInfix = false,
isExternal = false,
containerSource = null,
isFakeOverride = false
)
val function = KotlinAdapterLoader.current.createSimpleFunction(
factory = context.irFactory,
startOffset = UNDEFINED_OFFSET,
endOffset = UNDEFINED_OFFSET,
origin = IrDeclarationOrigin.DEFINED,
name = hintName,
visibility = DescriptorVisibilities.PUBLIC,
returnType = context.irBuiltIns.unitType,
isSuspend = false,
symbol = IrSimpleFunctionSymbolImpl(),
)

// Add parameter with the target class type (erased to raw form for generics — see #18)
val params = mutableListOf<IrValueParameter>()
Expand Down Expand Up @@ -380,25 +373,17 @@ class DslHintGenerator(
// An incomplete module MUST emit even with nothing readable — the marker is the payload.
if (included.isEmpty() && !emitWhenEmpty && !incomplete) return null

val function = context.irFactory.createSimpleFunction(
startOffset = UNDEFINED_OFFSET,
endOffset = UNDEFINED_OFFSET,
origin = IrDeclarationOrigin.DEFINED,
name = Name.identifier(KoinPluginConstants.dslIncludesHintFunctionName(ownerModuleId)),
visibility = DescriptorVisibilities.PUBLIC,
isInline = false,
isExpect = false,
returnType = context.irBuiltIns.unitType,
modality = Modality.FINAL,
symbol = IrSimpleFunctionSymbolImpl(),
isTailrec = false,
isSuspend = false,
isOperator = false,
isInfix = false,
isExternal = false,
containerSource = null,
isFakeOverride = false
)
val function = KotlinAdapterLoader.current.createSimpleFunction(
factory = context.irFactory,
startOffset = UNDEFINED_OFFSET,
endOffset = UNDEFINED_OFFSET,
origin = IrDeclarationOrigin.DEFINED,
name = Name.identifier(KoinPluginConstants.dslIncludesHintFunctionName(ownerModuleId)),
visibility = DescriptorVisibilities.PUBLIC,
returnType = context.irBuiltIns.unitType,
isSuspend = false,
symbol = IrSimpleFunctionSymbolImpl(),
)

// One Unit-typed parameter per included module, using the same `module_<id with . → $>`
// encoding the definition hints already use for modulePropertyId, so decoding is symmetric.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.koin.compiler.plugin.KoinPluginLogger
import org.koin.compiler.plugin.fir.KoinModuleFirGenerator
import kotlin.io.path.Path
import kotlin.io.path.absolutePathString
import org.koin.compiler.adapter.KotlinAdapterLoader

/**
* Generates and discovers `injectedparams_<flat-fqn>(...)` hint functions in
Expand Down Expand Up @@ -223,25 +224,17 @@ class InjectedParamHintGenerator(
return
}

val function = context.irFactory.createSimpleFunction(
startOffset = UNDEFINED_OFFSET,
endOffset = UNDEFINED_OFFSET,
origin = IrDeclarationOrigin.DEFINED,
name = hintName,
visibility = DescriptorVisibilities.PUBLIC,
isInline = false,
isExpect = false,
returnType = context.irBuiltIns.unitType,
modality = Modality.FINAL,
symbol = IrSimpleFunctionSymbolImpl(),
isTailrec = false,
isSuspend = false,
isOperator = false,
isInfix = false,
isExternal = false,
containerSource = null,
isFakeOverride = false,
)
val function = KotlinAdapterLoader.current.createSimpleFunction(
factory = context.irFactory,
startOffset = UNDEFINED_OFFSET,
endOffset = UNDEFINED_OFFSET,
origin = IrDeclarationOrigin.DEFINED,
name = hintName,
visibility = DescriptorVisibilities.PUBLIC,
returnType = context.irBuiltIns.unitType,
isSuspend = false,
symbol = IrSimpleFunctionSymbolImpl(),
)

val params = mutableListOf<IrValueParameter>()
for ((index, sourceParam) in injectedSourceParams.withIndex()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.jetbrains.kotlin.ir.declarations.IrValueParameter
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression
import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression
import org.jetbrains.kotlin.name.Name

/**
* Helpers over the unified IR parameters/arguments API (Kotlin 2.3.20+).
Expand Down Expand Up @@ -38,6 +39,15 @@ internal fun IrFunctionAccessExpression.getRegularArgument(index: Int): IrExpres
return arguments[param.indexInParameters]
}

/**
* Reads the argument for the callee's REGULAR parameter named [name] — the old
* `IrUtils.getValueArgument(IrConstructorCall, Name)`, removed in Kotlin 2.4.20.
*/
internal fun IrFunctionAccessExpression.getRegularArgument(name: Name): IrExpression? {
val param = symbol.owner.regularParameters.firstOrNull { it.name == name } ?: return null
return arguments[param.indexInParameters]
}

/** Number of regular arguments — the old `valueArgumentsCount`. */
internal val IrFunctionAccessExpression.regularArgumentsCount: Int
get() = symbol.owner.regularParameters.size
Expand Down
Loading