Skip to content

Fix #2406, #2435: qualified requests no longer pick up stacked parameters#2440

Closed
ChristophyBarth wants to merge 1 commit into
InsertKoinIO:mainfrom
ChristophyBarth:fix/2406-2435-qualified-stacked-params
Closed

Fix #2406, #2435: qualified requests no longer pick up stacked parameters#2440
ChristophyBarth wants to merge 1 commit into
InsertKoinIO:mainfrom
ChristophyBarth:fix/2406-2435-qualified-stacked-params

Conversation

@ChristophyBarth

Copy link
Copy Markdown

Problem

A get(named(...)) could be satisfied by a same-typed value sitting on the scope's
parameter stack, shadowing the qualified definition. So passing parametersOf("event-id")
to one dependency could bleed that String into an unrelated @Named String further down
the graph (#2435), and checkKoinModules handed get(named("env")) the MockParameter
default "" instead of the named single (#2406).

Cause

In CoreResolverV2, resolution tries the parameter stack before the registry. Parameters
match by type only and carry no qualifier, so a qualified request would match whatever
same-typed value was on the stack.

Fix

resolveFromStackedParameters now returns null when the request has a qualifier, letting
it fall through to the registry. This mirrors the rule already used by
resolveFromScopeSource.

Behavioral change

Qualified resolutions could previously return a stacked parameter of the matching type;
they now always resolve from definitions. Unqualified resolution, including the #2387
stacked-parameter path, is unchanged.

Tests

Added cases in ParametersInjectionTest (root, scope, and linked-scope variants) and
CheckModulesTest. Verified on JVM, wasmJs, and native.

Closes #2406
Closes #2435

…er pick up stacked parameters

A get(named(...)) could be satisfied by a same-typed value on the scope
parameter stack, shadowing the qualified definition. Parameters match by
type only and carry no qualifier, so resolveFromStackedParameters now skips
the stack when a qualifier is present (same rule as resolveFromScopeSource)
and falls through to the registry.

Behavioral delta: qualified resolutions could previously return a stacked
parameter of the matching type; they now always resolve from definitions.
Unqualified resolution (incl. InsertKoinIO#2387) is unchanged.

Tests added in ParametersInjectionTest and CheckModulesTest. Verified on
JVM, wasmJs and native.
@ChristophyBarth ChristophyBarth force-pushed the fix/2406-2435-qualified-stacked-params branch from 8767c58 to 71c1695 Compare June 11, 2026 15:03
@ChristophyBarth

Copy link
Copy Markdown
Author

Closing — this was fixed independently on main by 4fae618 (#2370/#2408), which makes the identical change in CoreResolverV2. I'll open a small follow-up PR with the docs note and the checkmodules-path test coverage that aren't on main yet.

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.

Broken checkKoinModules functionality on get<String> CoreResolverV2 using injected param instead of named

1 participant