Repository navigation
feat(resolve): root an inferred receiver's type name in the file it was written in (slices 1-2) - #331
Merged
Merged
Conversation
…as written in (slice 1: field hops) An inferred receiver (`holder.model.text`) carried only the type's bare name; the member lookup then re-resolved that name against the CALLER's imports, so a type the caller never imports (and any same-named decoy elsewhere) broke it. ResolvedType now carries `declaring_uri` (the per-hop Url the inference layer already tracked and CstQuery::expr_type dropped; the deferred note in the qualified-resolution design spec). SymbolRole::Reference holds Option<ResolvedType> and resolve_identity uses Indexer::find_member_of_type, which resolves the type root in `declaring_uri` while extension scope stays the caller's (resolve_qualified_in_type_scope). A `jar:` origin keeps the caller's scope. Call hops still return the caller's file as origin (slice 2). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A call's return type is spelled in the callee's file (loadScreenData's `ScreenFlowModel<out IProductScreenTexts>` is imported there, not by the caller), but call hops reported the caller's file as the origin, so the slice-1 member lookup still re-resolved the name against the caller. - resolver: DeclaredReturn / find_method_return_type_declared / find_method_return_type_via_supertypes_declared keep the declaring file next to the return type; Resolver::method_return_type_declared is the catalogue composite (the old method_return_type is now a test-only convenience). A supertype substitution is attributed to the subclass file that spelled `Base<Int>`. - InferDeps::find_method_return_type_with_origin_for_type (provided method, Indexer overrides; JAR/extension-registry answers report no file and keep the caller as origin). - chain.rs: StrategyOutcome carries the origin; finalize applies the head rule — when the declared head is a type parameter the receiver's type argument replaced, the name was spelled with the receiver, not the member. Scope functions pass the receiver's origin through. - resolve_field_type_on / resolve_method_return_type_on apply the same head rule per hop. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This was referenced Oct 6, 2026
…types wrapper and ReturnType re-export CI builds tests with RUSTFLAGS=-D warnings; the origin-carrying composite made both unused. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Package-qualified types, source extensions, and explicit generic return substitutions can still use the wrong resolution scope.
Review effort: Balanced
Findings: 1
Open (3)
What changed in this PR
Adds declaration-origin tracking to inferred receiver types so chained member resolution uses the file where each type was written.
Changes:
- Adds origin-aware
ResolvedTypeand method-return inference. - Resolves receiver members using declaration scope while retaining caller extension scope.
- Adds decoy-backed field, call, and generic-substitution tests.
| File | Description |
|---|---|
src/resolver/tests.rs |
Updates anchor calls for separate type and caller scopes. |
src/resolver/resolve.rs |
Adds type-scope-aware symbol resolution. |
src/resolver/qualified.rs |
Separates type-root and caller extension scopes. |
src/resolver/mod.rs |
Updates resolver exports. |
src/resolver/infer.rs |
Returns method types with declaration origins. |
src/resolver/api.rs |
Exposes origin-aware method return lookup. |
src/indexer/lookup.rs |
Adds origin-aware member lookup APIs. |
src/indexer/infer/mod.rs |
Extends ResolvedType with its declaring URI. |
src/indexer/infer/expr_type.rs |
Preserves origins during expression inference. |
src/indexer/infer/deps.rs |
Adds origin-aware inference dependency lookup. |
src/indexer/infer/cst_symbol.rs |
Carries ResolvedType through symbol classification. |
src/indexer/infer/cst_symbol_tests.rs |
Adds cross-package origin regression tests. |
src/indexer/infer/chain.rs |
Propagates origins across fields, calls, and substitutions. |
src/indexer.rs |
Implements origin-aware method return lookup. |
src/features/unresolved_symbol_diagnostics.rs |
Adapts diagnostics to structured receiver types. |
src/features/references.rs |
Adapts reference discovery to structured receiver types. |
src/features/references_verify.rs |
Adapts receiver verification. |
src/features/implementation.rs |
Adapts implementation lookup. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…iew on #331) - TypeScope (file + optional package) replaces a bare Url for where a qualifier's type name resolves; a package-qualified spelling (types.Payload) resolves its root through the fully-qualified index and constrains candidates to that package. extract_return_type_from_detail now accepts a package-qualified return type (it read a lowercase first segment as 'no declared type'). - an explicit call-site type argument that replaces the return head (create<Foo>()) was spelled at the call site: origin = caller - a source extension function's return type reports the selected entry's declaring file (find_extension_fn_return_type_declared); JAR files keep the caller-scope fallback Co-Authored-By: Claude Sonnet 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.


Problem
An inferred receiver (
screenFlowInteractor.loadScreenData(refresh = false).text.scenes) carried only the type's bare name. The member lookup then re-resolved that name against the caller's imports, so a type the caller never imports — and any same-named decoy elsewhere (Moneta has 6+ScreenFlowModel) — turned.textinto a Gap although the index holdsScreenFlowModel.text.Design
Follows the deferred note in
docs/superpowers/specs/2026-08-24-qualified-resolution-unification-design.md(per-hopUrlbecomes a field onResolvedType) and the CST-unification spec (no bareStringon the surface; no cross-domain IR).ResolvedTypecarriesdeclaring_uri(+type_path(),resolution_scope());CstQuery::expr_typestops dropping the origin the inference layer already tracked.SymbolRole::Reference.receiver_type: Option<ResolvedType>;Indexer::find_member_of_typeresolves the type root in the origin file (resolve_qualified_in_type_scope) while extension scope stays the caller's. Ajar:origin keeps the caller's scope (unchanged behaviour).DeclaredReturn,Resolver::method_return_type_declared,InferDeps::find_method_return_type_with_origin_for_type).StrategyOutcomecarries the origin; the head rule attributes a substituted type-parameter head to the receiver's file, not the member's. Scope functions pass the receiver's origin through.Tests (red before)
field_hop_member_resolves_in_the_file_the_receiver_type_was_written_in(+ origin assertion)call_hop_member_resolves_in_the_file_the_return_type_was_written_inmember_of_a_substituted_type_argument_resolves_in_the_receivers_originAll use three packages with same-named, same-member decoys and assert the exact resolved file.
cargo test(2041),clippy -D warnings,fmtclean.Moneta (
resolution-accuracy Moneta/android, 13,325 files)member recall 92.0% → 92.9%; member Gap 8,844 → 7,383; FilteredCandidate 7,830 → 7,548;
text310→186,scenes182→127,title218→176.Follow-ups (stacked next): slice 2b (
foo().barorigin), slice 3 (sibling sites: implicit-receiver member match, references-verify agreement anchor,value_path_anchor).🤖 Generated with Claude Code