Skip to content

Fix duplicate injectedparams_* IR signatures on KLIB targets (iOS/wasmJs)#55

Merged
arnaudgiuliani merged 1 commit into
1.0.1from
arnaud/ktz-4151-injectedparams-ir-dup
Jun 9, 2026
Merged

Fix duplicate injectedparams_* IR signatures on KLIB targets (iOS/wasmJs)#55
arnaudgiuliani merged 1 commit into
1.0.1from
arnaud/ktz-4151-injectedparams-ir-dup

Conversation

@arnaudgiuliani

Copy link
Copy Markdown
Member

Problem

On non-JVM targets (iOS native, wasmJs/JS), the plugin failed KLIB serialization with:

Different declarations with the same signatures ... FUN name:injectedparams_<fqName> ... (declared twice)

(compiler#44 iOS, the first wall of compiler#40 wasmJs). JVM tolerates duplicate IR signatures; KLIB serialization does not.

Root cause

getAllKnownDefinitions() flat-maps definitions across modules, so a target type collected by more than one @ComponentScan module appears multiple times. InjectedParamHintGenerator emitted the injectedparams_<fqName> hint once per definition — duplicate IR functions with identical signatures.

Fix

Emit the hint exactly once per target (gate on localSlots.putIfAbsent(...) == null). Targets reaching this point are non-ambiguous (identical shape), so a single hint is correct.

Verification

  • New box regression test injected_param_dual_definition_single_hint (two @ComponentScan modules over the same target): asserts a single injectedparams_ function (was 2 pre-fix).
  • Full box suite green.
  • iosArm64: reproduced the exact version 1.0.0 fail in buid time iOS when use @InjectedParam #44 error pre-fix → BUILD SUCCESSFUL post-fix (real iosArm64 compile).

Fixes #44 · refs #40

Stacked on #52 (Kotlin 2.3.20/2.4.0 compat). Merge #52 first; this PR's diff narrows to its own changes afterward.

🤖 Generated with Claude Code

…ed by multiple modules

A target type collected by more than one @componentscan module (getAllKnownDefinitions
flat-maps definitions across modules) emitted the injectedparams_<fqName> hint function
once per definition. Identical signatures are tolerated on JVM but a hard KLIB
serialization failure on Native/JS/Wasm (compiler#40, #44).

Emit the hint exactly once per target FqName (gate on localSlots.putIfAbsent). Since
only non-ambiguous targets reach this point, they share an identical shape, so a single
hint is correct.

Adds box regression test injected_param_dual_definition_single_hint (two @componentscan
modules over the same @InjectedParam target): asserts a single injectedparams_ function
(was 2 pre-fix). Full box suite green.

Refs #40, #44
@arnaudgiuliani arnaudgiuliani merged commit 1dd4ec2 into 1.0.1 Jun 9, 2026
2 checks passed
@arnaudgiuliani arnaudgiuliani deleted the arnaud/ktz-4151-injectedparams-ir-dup branch July 10, 2026 12:53
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