Skip to content

fix(kotlin): a parenthesized infix receiver is typed like a bare one - #475

Merged
bompus merged 2 commits into
fork/consolidatedfrom
fix/kotlin-infix-paren-receiver
Oct 12, 2026
Merged

bompus merged 2 commits into
fork/consolidatedfrom
fix/kotlin-infix-paren-receiver

Conversation

@bompus

@bompus bompus commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

A Kotlin infix call written with a parenthesized receiver, (b) put 1, now links to the put of b's class instead of whichever class has a put.

What changed

  • extract_infix_call in codegraph-kernel/src/kotlin/calls.rs peeled no parentheses, so (b) put 1, (b)put(1) and ((b)) put (1) recorded a plain put call, and the resolver matched it by name. With b: A and another class B that also declares put, the call landed on B::put. The receiver is now peeled and recorded as b.put, so it is typed like b put 1.
  • One existing case changes. (value) and mask with a project class named Int and infix fun Int.and(...) used to link by name; it now has no edge, the same as value and mask and value.and(mask) already did. An extension on a project class called through a typed receiver is not linked today in any form (found while checking this; not changed here). I changed that case's expectation to [] and said why in the test.

Evidence

Check Before After
(b) put 1, (b)put(1), ((b)) put (1) with b: A, another B.put B::put A::put
Exposed (803 Kotlin files), call edges from functions and methods 26,834 26,834, no edge differs
Golden dumps unchanged unchanged

The new test fails on the base and passes here. Full suite: 695 files, 8,902 passed, 39 skipped, no worker-crash lines.

README rows checked: the Kotlin infix row (updated), no other row mentions parenthesized receivers. CHANGELOG entry added.


Summary by cubic

A Kotlin infix call with a parenthesized receiver, (b) put 1, now links to the put of b's class instead of whichever class has a put. The receiver was recorded as empty, so the resolver matched the callee purely by name; it is now peeled of parenthesis layers and recorded as b.put, matching how a bare b put 1 is typed.

One case changes: (value) and mask with a project class named Int and infix fun Int.and(...) previously linked by name and now produces no edge, the same as value and mask already did; an extension on a project class called through a typed receiver is not linked in any form today. The test places the typed class between two others that declare the same put, so the edge proves the receiver's type chose it, not order or name.

Written for commit 01337a8. Summary will update on new commits.

View guided diff Turn on auto-fix

Summary by CodeRabbit

  • Bug Fixes
    • Kotlin infix calls with parenthesized receivers now resolve according to the receiver’s type, avoiding incorrect matches to same-named methods on other classes.
    • Added coverage for bare and parenthesized receivers, including tightly written calls and parenthesized arguments.

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository YAML (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0240b42a-53c2-4c7a-bcaa-9bce1db422d1

📥 Commits

Reviewing files that changed from the base of the PR and between 9b8b85e and 01337a8.


📒 Files selected for processing (4)
  • CHANGELOG.md
  • README.md
  • __tests__/kotlin-infix-calls.test.ts
  • codegraph-kernel/src/kotlin/calls.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.



📝 Walkthrough

Walkthrough

The Kotlin infix-call extractor now unwraps nested parentheses around the left operand before checking for a simple identifier receiver. Tests and documentation cover parenthesized receiver resolution and the project-defined numeric extension case.

Changes

Kotlin infix receiver resolution

Layer / File(s) Summary
Unwrap parenthesized infix receivers
codegraph-kernel/src/kotlin/calls.rs, __tests__/kotlin-infix-calls.test.ts, README.md, CHANGELOG.md
The extractor unwraps nested single-child parentheses before checking for a simple identifier receiver. Tests cover bare and parenthesized calls, competing methods, and the project-defined numeric extension case. The README and changelog describe the resolution behavior and existing extension limitation.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 01337

Parenthesized infix receivers now resolve through their declared type, matching bare receivers. No actionable merge risk is established; normal project checks still apply.

Pre-merge checks | Passed 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main Kotlin fix: parenthesized infix receivers now use the receiver's type like bare receivers.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Suppressions Explained Passed The pull request adds no lint, type-check, or compiler suppression directive. The changed lines contain only Kotlin logic, tests, documentation, and explanatory comments; no eslint-disable, `@ts-exp…
User-Visible Changes Documented Passed PASS. The reviewed diff changes Kotlin infix-call resolution and adds tests plus README/CHANGELOG text. It does not add, remove, or rename a CLI command or flag, MCP tool or argument, supported langua…

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR



🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 4 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread __tests__/kotlin-infix-calls.test.ts Outdated
@bompus
bompus merged commit 9695807 into fork/consolidated Oct 12, 2026
5 checks passed
@bompus
bompus deleted the fix/kotlin-infix-paren-receiver branch October 12, 2026 05:06
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.

1 participant