Skip to content

fix(completion): offer implicit receiver members in bare completion#203

Merged
Hessesian merged 1 commit into
Hessesian:mainfrom
hikkidev:fix/implicit-receiver-bare-completion
Jul 4, 2026
Merged

fix(completion): offer implicit receiver members in bare completion#203
Hessesian merged 1 commit into
Hessesian:mainfrom
hikkidev:fix/implicit-receiver-bare-completion

Conversation

@hikkidev

@hikkidev hikkidev commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Problem: Inside with(x) { }, x.apply { }, or x.run { }, bare identifier completion didn’t offer receiver members - only this. did.

Fix: Infer the implicit receiver type in those lambdas and merge its members into bare completion.

Inside with/apply/run lambdas, bare identifier completion now includes members of the inferred receiver type, matching explicit this. completion behavior.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves Kotlin completion inside receiver lambdas (e.g., with(x) { ... }, x.apply { ... }, x.run { ... }) by inferring the implicit receiver type and merging its members into bare identifier completion (so users don’t need to type this. to see receiver members).

Changes:

  • Add ScopeContext::lambda_this_type derived from find_this_context_in_lines to represent the resolved implicit receiver type specifically for receiver lambdas.
  • Extend bare-word completion to include implicit receiver members when ctx.receiver.is_none() (and not in annotation-only context), de-duplicating by label.
  • Add regression tests covering with/apply/run bare completion, a forEach negative case, and ensuring this. dot completion still works.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/indexer_tests.rs Adds completion regression tests for implicit receiver members in bare completion, plus a negative forEach case.
src/features/completion.rs Injects implicit receiver member completions into bare completion results.
src/features/completion_context.rs Introduces lambda_this_type in ScopeContext and resolves it via find_this_context_in_lines.
src/features/completion_context_tests.rs Updates struct literals for the new lambda_this_type field.

Comment thread src/features/completion_context.rs
@Hessesian Hessesian merged commit d4f956e into Hessesian:main Jul 4, 2026
4 checks passed
Hessesian added a commit that referenced this pull request Jul 4, 2026
…resolution

Ports the contribution onto the CST-era shapes: resolve_lambda_this_type
drops the text-lines argument (CursorPos::from(position) + the 3-arg
find_this_context_in_lines), and ScopeContext::build keeps its
position-only signature.

The contributor's mid-typing tests exposed the known repair-gap asymmetry:
`with(user) { this.` (unclosed brace) parses to an ERROR tree and the
`this` path had no brace repair — only `it` did. find_this_context_in_lines
now routes through the same repair-gated tree acquisition
(LambdaResolutionDoc, renamed from ItResolutionDoc since it was never
it-specific).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EJsyQ1UgF8uJYR4HgpxEBB
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.

3 participants