fix: parameter diagnostics correctly resolve extension functions#158
Open
Hessesian wants to merge 4 commits into
Open
fix: parameter diagnostics correctly resolve extension functions#158Hessesian wants to merge 4 commits into
Hessesian wants to merge 4 commits into
Conversation
Hessesian
added a commit
that referenced
this pull request
Jun 3, 2026
dd03b63 to
fd375f8
Compare
Hessesian
added a commit
that referenced
this pull request
Jun 3, 2026
Replaced the complex resolve_qualified (141 lines, cognitive complexity 36) with a clean 80-line implementation that reuses the existing build_result helper for deduplication. Two-phase approach: 1. Search definitions index filtering by receiver type (container for members, extension_receiver for extensions) 2. Fall back to extension_by_receiver for JAR-only extensions 1253 tests pass, clippy clean (zero warnings).
fd375f8 to
82419ae
Compare
Hessesian
commented
Jun 3, 2026
|
|
||
| // Phase 1: definitions index — source-indexed members and extensions. | ||
| if let Some(locs) = idx.definitions.get(call.name) { | ||
| for loc in locs.iter() { |
Hessesian
commented
Jun 3, 2026
| .filter(|s| { | ||
| if s.name != call.name { | ||
| return false; | ||
| let type_name = rt.leaf.as_str(); |
Hessesian
commented
Jun 3, 2026
| let params_text = if !sym.params.is_empty() { | ||
| sym.params.clone() | ||
| } else if let Some(p) = extract_params_from_detail(&sym.detail) { | ||
| p |
Owner
Author
There was a problem hiding this comment.
fix shortcuts in this whole file
There was a problem hiding this comment.
Pull request overview
This PR fixes call-argument diagnostics for qualified calls so they resolve the correct target when both member functions and extension functions exist—especially for cross-file/JAR extensions—preventing incorrect parameter-count diagnostics.
Changes:
- Refactors
resolve_qualifiedin signature inference to prefer receiver-type matching for members/extensions and adds an extension-by-receiver fallback. - Adds new diagnostics regression tests covering same-file and cross-file extension function argument counts.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/indexer/infer/sig.rs |
Rewrites qualified-call signature resolution to filter candidates by inferred receiver type and reuse shared result-building logic. |
src/features/call_arg_diagnostics_tests.rs |
Adds regression tests for qualified extension functions (same-file and cross-file) to validate correct arg-count diagnostics behavior. |
Comment on lines
+778
to
+779
| let matches = sym.container.as_deref() == Some(type_name) | ||
| || (sym.container.is_none() && sym.extension_receiver == type_name); |
Comment on lines
+801
to
+804
| if entry.name != call.name { | ||
| continue; | ||
| } | ||
| let Some(data) = idx |
Comment on lines
+802
to
+808
| let src = [ | ||
| "class IMockProvider", | ||
| "inline fun <reified T> IMockProvider.loadJSONFromAssets(path: String): T = TODO()", | ||
| "class Foo(private val context: IMockProvider) {", | ||
| " val result = context.loadJSONFromAssets(\"test\")", | ||
| "}", | ||
| ] |
Comment on lines
+826
to
+832
| let src = [ | ||
| "class IMockProvider", | ||
| "fun IMockProvider.loadJSONFromAssets(path: String): Any = TODO()", | ||
| "class Foo(private val context: IMockProvider) {", | ||
| " val result = context.loadJSONFromAssets()", | ||
| "}", | ||
| ] |
…ing member tests - Rename type_name → receiver_base to match resolver convention - Replace rt.leaf.as_str() with &rt.leaf, deref comparisons via .as_str() - Add comment explaining why leaf (not qualified) is correct for container/extension_receiver matching - Split inline boolean into is_member / is_extension for readability (no shortcuts) - Add competing member definitions to extension tests per Copilot review: - extension_fn_resolved_not_member: add unrelated Service.loadJSONFromAssets() member - extension_fn_wrong_arg_count_detected: add unrelated 0-arg competitor
…, diags→diagnostics
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.
Summary
Fixes parameter diagnostics to correctly resolve extension functions (both same-file and cross-file/JAR) when checking argument counts. Previously, diagnostics could report wrong parameter counts from member functions instead of the correct extension function.
Changes
src/indexer/infer/sig.rs— Simplifiedresolve_qualifiedbuild_resulthelper for deduplicationdefinitionsindex filtering by receiver type (containerfor members,extension_receiverfor extensions)extension_by_receiverfor JAR-only extensionssrc/features/call_arg_diagnostics_tests.rs— Cross-file extension testsTest Results