Skip to content

fix: no compiler crash on local classes / anonymous objects in DSL (#101) - #130

Merged
arnaudgiuliani merged 3 commits into
1.2.2from
fix/ktz-5219-local-class-dsl-hint
Oct 27, 2026
Merged

arnaudgiuliani merged 3 commits into
1.2.2from
fix/ktz-5219-local-class-dsl-hint

Conversation

@arnaudgiuliani

@arnaudgiuliani arnaudgiuliani commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Fixes #101 (also the follow-up comment on #89).

Problem

A DSL definition whose type is a local class or an anonymous object (single { FakeRepo() }, factory { object : Clock {} }, typical in test fixtures) crashed the compiler:
IrGenerationExtensionException: No classId for IrClassImpl. Such types have no ClassId, so they can't be written into a cross-module hint. Same crash for a get<T>() on an undefined local class in a module with no Koin entry point.

Fix

  • DSL hints: skipped when the definition's type or its type qualifier has no ClassId; bindings without one are dropped. No other module can name these types anyway.
  • Call sites: a get<T>() on a local class is never deferred to a downstream module (none can provide it). It now reports KOIN-D002 in place instead of crashing.
  • test-apps: built against this checkout's pluginVersion (was pinned to 1.0.2-Beta1), iosArm64 added, Kotlin 2.3.20 → 2.4.20 (JS/wasm with @ComponentScan crashed on 2.3.20, KT-82395, on every plugin version). PR Guard New koin compiler plugin Unrecognized @ScopeId #2 command added to CLAUDE.md.

Behavior change

Only where the compiler used to crash: an unresolved local-class call site now fails with KOIN-D002. No change for code that compiled before.

Proof

Check Unfixed Fixed
Box safety/local_class_dsl_no_crash (local class, anonymous object, local bind, local named<T>() qualifier) crash No classId OK
Diagnostics call_site_local_class_no_entry_point_d002 crash No classId KOIN-D002
Type-qualifier guard removed alone crash No classId —
Full suite — 462/462, no unrelated golden changes
KMP repro, Kotlin 2.4.20, jvm + wasmJs + iosArm64 1.2.1: all 6 tasks crash DSL module compiles; call-site module → KOIN-D002 on all 3
test-apps jvm + js + wasmJs + iosArm64 + jvmTest — green

arnaudgiuliani and others added 3 commits October 26, 2026 16:52
A DSL definition whose inferred type is a local class or anonymous object
has no ClassId, so writing its hint crashed with "No classId for IrClassImpl".
Such types can't be named from another module, so the hint is skipped
(and bindings without a ClassId are dropped).

WIP: RED proof, type-qualifier test, CallSiteValidator audit and
native/wasm gates still pending.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A get<T>() on a local class or anonymous object with no definition was
deferred as a call-site hint when the module had no entry point, crashing
with "No classId for IrClassImpl". No other module can provide such a
type, so it now fails here with KOIN-D002 instead of being deferred.

Tests: new diagnostics test for the call-site case; box test now also
covers a local type qualifier (named<LocalTag>()). All proven RED on the
unfixed code.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… 2.4.20

test-apps pinned plugin 1.0.2-Beta1 and had no native target, so it could
not serve as the native/wasm gate PR Guard #2 asks for. The plugin version
now comes from the repo's pluginVersion (override: -PkoinPluginVersion).
Kotlin moves 2.3.20 -> 2.4.20: JS/wasm with @componentscan crash on 2.3.20
(KT-82395) on every plugin version since 1.0.2-Beta1.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@arnaudgiuliani
arnaudgiuliani merged commit 3b508c0 into 1.2.2 Oct 27, 2026
2 checks passed
@arnaudgiuliani
arnaudgiuliani deleted the fix/ktz-5219-local-class-dsl-hint branch October 27, 2026 09:03
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