redhat-et / redhat-et/ripwire

Kotlin scope functions (`run`, `let`, `apply`, `also`, `with`) bind to unrelated Java methods

Open
#155 0 comments 0 reactions 0 assignees View on GitHub
help wanted
Dominant language
C++
Stars
2.1k
Forks
125
Avg merge
5h 42m
Merged PRs (30d)
136

Description

## What is wrong

Kotlin's scope functions are standard-library calls, but ripwire resolves calls by name. Once Kotlin
and Java share one call graph, `x.run { … }` binds to a same-named Java `run()` whenever the Kotlin
side defines no `run` of its own. `apply`, `let`, `also` and `with` do the same. Removing these
false edges is what makes `--callers`, `--impact` and the ranking trustworthy in mixed Java/Kotlin
codebases — Android above all.

## The evidence

On square/retrofit, `--callers=run` goes from **2 on `main` to 5** with the Kotlin support PR
(#126). Two of the three new rows are `.run { User(name) }` lambdas in Kotlin serialization tests —
false edges. The third is a real `block.run()` on a `Runnable`, which the fix **must keep**.

The kit records why the obvious levers cannot fix this on their own: arity, receivers,
own-language-first, and the external-name veto are each examined and ruled out, with three
reproduction trees and their recorded output.

## Size

**Medium.** One extracted per-call-site fact carried through the reference cache record (with parser
and cache version bumps, their mirrors and pins), a small sorted name table in
`src/externalnames.h`, a candidate filter beside `keepOwnJvmLanguageCandidates`, a new section in
`test/kotlincheck.sh`, and measurements on retrofit, nowinandroid and ktor.

## Prerequisites

- PR #126 (Kotlin support), still open. The prompt describes the code #126 adds and how to confirm
the integrated head. The arms go into `test/kotlincheck.sh`, which #126 adds.
- PR #136 (declined-call disclosure), merged into `main`. The disposition arm relies on its
conservation line.

## Where to start

`prompts/help-wanted/kotlin-scope-functions.md` is a self-contained prompt for a coding agent. It
covers the retrofit rows, how Kotlin calls are captured and resolved, the three reproductions, the
design space (the trailing-lambda fact, the name table, the rule, where refused sites go, and what
stays out of scope), the non-negotiables, red-first acceptance arms, the known traps, and what the
fix PR's description must contain. Like every prompt in `prompts/`, **it ends by writing a plan and
stopping** — a maintainer agrees the plan before any code is written.

Comment here to claim it.

Contributor guide

Open the contributing guide

Research direction

Start with prompts/help-wanted/kotlin-scope-functions.md and confirm the integrated head of PR #126. Then inspect the reference cache record, src/externalnames.h, the filter beside keepOwnJvmLanguageCandidates, and the new test/kotlincheck.sh section. Done means Kotlin scope-function calls no longer create unrelated Java edges, while a real block.run() remains and the red-first acceptance arms pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, java, kotlin, shell
Domain
cli, devtools, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.