Skip to content

Kotlin 2.4.0 support#191

Closed
LionZXY wants to merge 8 commits into
touchlab:mainfrom
LionZXY:feature/kotlin_240
Closed

Kotlin 2.4.0 support#191
LionZXY wants to merge 8 commits into
touchlab:mainfrom
LionZXY:feature/kotlin_240

Conversation

@LionZXY

@LionZXY LionZXY commented Jun 3, 2026

Copy link
Copy Markdown

Adds Kotlin 2.4.0 (release) to the supported versions

Compiler-internal API changes

Isolated in the ..2.3.20 / 2.4.0.. version source sets; the shared main
source set stays version-agnostic

  • Renamed typesKonanConfigNativeSecondStageCompilationConfig,
    KonanConfigKeysNativeConfigurationKeys, PhaseContextNativePhaseContext.
  • Removed IR APIsvalueParameters / putValueArgument / putTypeArgument /
    extensionReceiver(Parameter)skie* shims over the new positional
    parameters / arguments lists; IrMutableAnnotationContainer.annotations
    element type → IrAnnotation; GeneratorContext constructor change.
  • Config APIsCompilerConfiguration.reportMessageCollector,
    OUTPUT key → KONAN_OUTPUT_PATH, non-subclassable CompilerConfigurationKey.

⚠️ Behavior change

UserVisibleIrModulesSupport was removed in 2.4.0 with no replacement that maps
resolved libraries back to dependency coordinates. On 2.4.0, external
dependencies are no longer reported — all non-distribution libraries are treated
as local, and per-module analytics no longer distinguish external libraries.

Validation

  • Functional acceptance tests: 968/968 pass locally on 2.4.0 (macos_arm64).
  • Type-mapping acceptance tests: pass locally on 2.4.0.
  • The merged tree compiles for 2.4.0, 2.3.21 and 2.3.20.
  • expected-failures for 2.4.0 are seeded from 2.3.20 — to be finalized from the
    CI external-library runs.

cc: #187

LionZXY added 8 commits June 3, 2026 15:59
Register 2.4.0 (release) in versionSupport.kotlin and switch dev-support to it.

SKIE keeps compiling with the 2.2.20 Kotlin compiler (which still supports
experimental context receivers). That compiler reads klib metadata only one
minor version ahead, so building against the 2.4.0 Kotlin/Native distribution
needs -Xskip-metadata-version-check; it is added in BaseKotlinPlugin for every
JVM module (main and test) when the primary Kotlin version is >= 2.4.0.
Kotlin 2.4.0 renamed several Kotlin/Native compiler types:
- KonanConfig      -> NativeSecondStageCompilationConfig
- KonanConfigKeys  -> NativeConfigurationKeys
- PhaseContext     -> NativePhaseContext

The shared `main` source set now references SKIE-internal typealiases
(co.touchlab.skie.compat.{KonanConfig,KonanConfigKeys,PhaseContext}) defined
per version range (`..2.3.20` -> old names, `2.4.0..` -> new names). The
debugPrefixMapKey/phaseContextKonanConfig version helpers are bounded to
exactly 2.3.20 and reimplemented for 2.4.0+ against the new types.
Kotlin 2.4.0 removed the dedicated IR value-parameter/receiver/argument
accessors (valueParameters, putValueArgument, putTypeArgument,
extensionReceiver, extensionReceiverParameter) in favor of unified positional
parameters/arguments lists, changed IrMutableAnnotationContainer.annotations
to List<IrAnnotation>, and made the GeneratorContext primary constructor
private (the public one gained a CompilerConfiguration parameter).

The shared `main` source set now uses skie* shims and a
skieCreateGeneratorContext helper, implemented per version range, plus a
SkieIrAnnotation alias for the annotation element type.
…dulesSupport removal

- CompilerConfiguration.report(severity, message, location) was removed; SKIE
  now reports through the MessageCollector (reportCompilerMessage shim).
- The framework OUTPUT key was renamed to KONAN_OUTPUT_PATH
  (frameworkOutputPathConfigurationKey shim).
- CompilerConfigurationKey is final; SkieConfigurationKeys holds key instances
  instead of subclassing it.
- UserVisibleIrModulesSupport was removed with no replacement that maps
  resolved libraries to dependency coordinates. getExternalDependencies returns
  an empty set on 2.4.0, so all non-distribution libraries are treated as local
  and per-module analytics no longer distinguish external libraries. Default
  libraries are now detected via KotlinLibrary.isFromKotlinNativeDistribution.
# Conflicts:
#	common-gradle/gradle.properties
#	dev-support/build.gradle.kts
`generateCIActions` regenerates every versioned smoke-test workflow, which
incidentally re-synced the stale smoke-tests-2_3_20-*.yml (its lockfile was
shrunk in b88ae64 without regenerating the workflow). That change is unrelated
to Kotlin 2.4.0 support, so restore those two files to match main and keep this
PR scoped to 2.4.0.
Comment on lines +83 to +95
private fun Project.extraJvmCompilerArgs(): List<String> = buildList {
add("-Xjdk-release=${libs.versions.jvmTarget}")

// The project is compiled with the Kotlin compiler pinned in the version catalog (see `kotlin`), which can only
// read klib metadata up to one minor version ahead. Compiling against a newer Kotlin distribution (2.4.0+, used
// by the kotlin-native-compiler-embeddable on the main/test classpath) therefore needs the metadata version
// check relaxed.
val primaryCompilerVersion = SupportedKotlinVersionProvider.getPrimaryKotlinVersion(this@extraJvmCompilerArgs).compilerVersion
if (primaryCompilerVersion >= KotlinToolingVersion("2.4.0")) {
add("-Xskip-metadata-version-check")
}
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, this is necessary to avoid upgrading Kotlin to 2.3.* as part of this PR.
The main obstacle to this is: #190

@LionZXY

LionZXY commented Jun 4, 2026

Copy link
Copy Markdown
Author

What about this:

⚠️ Behavior change

UserVisibleIrModulesSupport has been removed from Kotlin, so there is no longer a way to determine whether this dependency is external.

Fortunately, SKIE uses a Gradle plugin, so it can pass this information.

I don’t really like this approach, so I didn’t include it in the main PR. There’s a separate PR for this here: LionZXY#4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant