Repository navigation
fix(kotlin): a parenthesized infix receiver is typed like a bare one - #475
Merged
Merged
Conversation
There was a problem hiding this comment.
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
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.
A Kotlin infix call written with a parenthesized receiver,
(b) put 1, now links to theputofb's class instead of whichever class has aput.What changed
extract_infix_callincodegraph-kernel/src/kotlin/calls.rspeeled no parentheses, so(b) put 1,(b)put(1)and((b)) put (1)recorded a plainputcall, and the resolver matched it by name. Withb: Aand another classBthat also declaresput, the call landed onB::put. The receiver is now peeled and recorded asb.put, so it is typed likeb put 1.(value) and maskwith a project class namedIntandinfix fun Int.and(...)used to link by name; it now has no edge, the same asvalue and maskandvalue.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
(b) put 1,(b)put(1),((b)) put (1)withb: A, anotherB.putB::putA::putThe 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 theputofb's class instead of whichever class has aput. The receiver was recorded as empty, so the resolver matched the callee purely by name; it is now peeled of parenthesis layers and recorded asb.put, matching how a bareb put 1is typed.One case changes:
(value) and maskwith a project class namedIntandinfix fun Int.and(...)previously linked by name and now produces no edge, the same asvalue and maskalready 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 sameput, so the edge proves the receiver's type chose it, not order or name.Written for commit 01337a8. Summary will update on new commits.
Summary by CodeRabbit