Kotlin Multiplatform "expect/actual" mismatch in commonMain in CI
In Kotlin Multiplatform, expect declarations in commonMain require a matching actual in every compiled target sourceSet. CI fails when a target compiled on the runner has no actual, or when signatures drift, because the mismatch is only checked when that target is built.
What this error means
A target compile task fails with "expected declaration has no actual declaration in module for JVM" or "actual ... has no corresponding expected declaration".
> Task :shared:compileKotlinJvm FAILED
e: /shared/src/commonMain/kotlin/Platform.kt: (3, 1): Expected function 'currentTime' has no
actual declaration in module shared.jvmMainCommon causes
A target sourceSet is missing an actual
CI builds a target (jvm, js, a native one) whose sourceSet never provided the actual for a common expect, so that target fails to compile.
Signatures drifted between expect and actual
A parameter or return type changed on one side, so the actual no longer matches the expect for that target.
How to fix it
Provide an actual for every compiled target
- Read which module/target the error names.
- Add the matching
actualin that target sourceSet with an identical signature. - Rebuild that target to confirm the pair matches.
// commonMain
expect fun currentTime(): Long
// jvmMain
actual fun currentTime(): Long = System.currentTimeMillis()Keep expect/actual signatures identical
Ensure names, parameters, and return types match exactly across all target sourceSets you compile in CI.
How to prevent it
- Add the actual in every target sourceSet the CI matrix builds.
- Keep expect and actual signatures byte-for-byte aligned.
- Compile all declared targets in CI so a missing actual is caught early.