Fix #2406, #2435: qualified requests no longer pick up stacked parameters#2440
Closed
ChristophyBarth wants to merge 1 commit into
Closed
Conversation
…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.
8767c58 to
71c1695
Compare
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A
get(named(...))could be satisfied by a same-typed value sitting on the scope'sparameter stack, shadowing the qualified definition. So passing
parametersOf("event-id")to one dependency could bleed that String into an unrelated
@NamedString further downthe graph (#2435), and
checkKoinModuleshandedget(named("env"))the MockParameterdefault
""instead of the named single (#2406).Cause
In
CoreResolverV2, resolution tries the parameter stack before the registry. Parametersmatch by type only and carry no qualifier, so a qualified request would match whatever
same-typed value was on the stack.
Fix
resolveFromStackedParametersnow returns null when the request has a qualifier, lettingit 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) andCheckModulesTest. Verified on JVM, wasmJs, and native.Closes #2406
Closes #2435