Repository navigation
fix: encode only validated requirements in cross-module DSL hints - #116
Closed
shreknitin89 wants to merge 1 commit into
Closed
shreknitin89 wants to merge 1 commit into
shreknitin89 wants to merge 1 commit into
Conversation
The req$i hint encoding carries only type and qualifier, and discoverDslDefinitionsFromHints rebuilds each requirement with isInjectedParam, hasDefault, isNullable and isList hard-coded false. Every @InjectedParam, defaulted, nullable or List<T> parameter of a DSL definition in another module therefore surfaced as a false KOIN-D001 at the startKoin entry point. Filter on requiresValidation() at the producer, where those flags are still known. Fixes InsertKoinIO#115 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
shreknitin89
force-pushed
the
fix/dsl-hint-skip-flags
branch
from
September 29, 2026 00:40
33121d9 to
0464e3f
Compare
Member
|
Your fix is re-embedded in #134. I will credit you on that part. Thanks for your work 🙏 |
arnaudgiuliani
added a commit
that referenced
this pull request
Oct 29, 2026
…004 (#115) (#134) A DSL definition validated from another module (e.g. an app consuming a feature module, or a module's own test compilation) was rebuilt from its hint with every per-parameter flag false. Parameters that need no provider became hard requirements → false KOIN-D001 on defaulted, nullable, List<T>, @InjectedParam, @Property, @provided and @Scopeid parameters; and a Lazy<T> edge became a hard cycle edge → false KOIN-D004 (DSL and annotation function-provider hints alike). - DSL hints carry Unit markers req<i>f_<flag> (+ req<i>sid_<name>) and the consumer decodes them. Hints from an older producer have none and decode as before; old consumers ignore the new markers. - The @Property key is not carried: KOIN-P001 is a same-module check, the consumer can't see the producer's @Propertyvalue declarations. - Annotation funcreqs hints carry an adjacent `lz` marker for Lazy<T>. Tests: 9 cross-module RED→GREEN tests (one per flag + Lazy cycle on both hint paths) and a guard that a missing Lazy<T> provider still reports D001. Golden diffs: only the new req0f_* hint parameters. Verified on nowinandroid: :app no longer reports false D001 for TopicViewModel(@InjectedParam topicId) / InterestsViewModel(@InjectedParam key). Supersedes #116 — thanks to Nitin Dasari for the original report and fix. Co-authored-by: Nitin Dasari <16711885+shreknitin89@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes #115.
Problem
buildRequirementParamsencodes each requirement asreq<i>_<name>, with only its type and qualifier. On the consuming side,discoverDslDefinitionsFromHintsrebuilds each requirement withisInjectedParam,hasDefault,isNullableandisListhard-coded tofalse. So a DSL definition in another Gradle module that has an@InjectedParam, defaulted, nullable orList<T>constructor parameter always produces a falseKOIN-D001at thestartKoinentry point.Change
Filter on
Requirement.requiresValidation()at the producer, where those flags are still known, before encoding. Requirements that don't need a provider never reach the hint, so the consumer's hard-coded flags no longer matter for them. The producer applies its ownskipDefaultValuessetting, which is the setting that also decided the generated code.Testing
I haven't run the test suite locally. My environment blocked building the plugin, so I'm relying on CI here. The diagnosis comes from the source plus 74 false positives in a real multi-module app, every one of them one of these four parameter kinds (see #115). A box test with a library module that exposes a DSL
viewModel<T>()taking an@InjectedParamparam and a defaulted param would pin this. I'm happy to add one if you point me at the preferred cross-module fixture.Possible follow-up (not in this change)
isLazyis also rebuilt asfalse.Lazy<T>requirements still need validation (onT), so they are still encoded, but a cycle check that relies onisLazyto breakLazyedges could see a falseKOIN-D004across modules. Encoding a lazy marker, like thereq<i>qn_qualifier companions, would close that.