Skip to content

fix(kotlin): extract extension functions with a generic or nullable receiver (#3608) - #3629

Merged
squid-protocol merged 2 commits into
mainfrom
claude/festive-fermat-kojuy7
Sep 25, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
claude/festive-fermat-kojuy7

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Closes #3608.

Problem

Kotlin func_start and args only accepted a plain [\w.]+ receiver. These were extracted as nothing:

  • fun Collection<CodeBlock>.joinToCode(...)
  • fun <T> List<T>.b()
  • fun Map<String, Int>.c() = 1
  • fun String?.d()

Fix

func_start and args now share one _RECEIVER fragment. It accepts:

  • a generic argument list, using the one-level-nesting idiom (Map<K, List<V>>), with bounded repetition so an unclosed < stays linear;
  • an optional nullable ?.

Verification

  • kotlinpoet, every .kt file, against tree-sitter function_declaration: recall went from 96.4% to 99.0% (2034 → 2090 of 2111). That is +56 functions and 0 new false positives: every newly extracted name is a tree-sitter function in the same file.
  • Tests: new valid, invalid and ReDoS cases in tests/extraction/languages/test_kotlin.py. The kotlin tests pass (150).
  • Golden masters: crucible_check.py --update --yes reports no drift in either fixture; the crucible's Kotlin samples have no generic receivers.
  • Other gates:
    • tree_sitter_accuracy_audit --lang kotlin --ci: OK.
    • import_graph_accuracy --ci: OK. Kotlin stays at 100/95.2. The remaining misses are extension properties (val KmClass.isObject), which are not functions and are out of scope here.
    • ruff: no new findings. mypy: kotlin.py has none. The only mypy findings locally were yaml stubs and re.sub overload issues in untouched files, caused by this environment.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YAtpBfGGyBGGovitSVaM5Q


Generated by Claude Code

…eceiver (#3608)

`func_start` and `args` only accepted a plain `[\w.]+` receiver, so
`fun Collection<CodeBlock>.joinToCode(...)`, `fun <T> List<T>.b()` and
`fun String?.d()` were not extracted at all. Both now share a `_RECEIVER`
fragment that takes a bounded, one-level-nested generic argument list and
an optional `?`.

kotlinpoet vs tree-sitter function_declaration: recall 96.4% -> 99.0%
(+56 functions, 0 new false positives). Golden masters unchanged (the
crucible's Kotlin samples have no generic receivers).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YAtpBfGGyBGGovitSVaM5Q
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

 follow-up)

#3627 stopped the Packed Payload Guard relegating import manifests, so the
crucible's three.js barrel `threejs/Nodes.js` (166 lines, 139 of them
`export ... from`) is scanned again: files_scanned 18 -> 19. It declares no
functions or classes, so every other count is unchanged. main's
tree-sitter-accuracy-audit has been red on this since #3627 merged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YAtpBfGGyBGGovitSVaM5Q

Copy link
Copy Markdown
Owner Author

tree-sitter-accuracy-audit failed on javascript (files_scanned: baseline=18 current=19). This PR didn't cause it: main has been red on the same check since #3627.

Bisect:

Cause: #3627 stopped the Packed Payload Guard from relegating import manifests. The crucible's three.js barrel threejs/Nodes.js (166 lines, 139 of them export … from) is scanned again. It declares no functions or classes, so every other count is unchanged.

Fix: the JavaScript baseline is regenerated in 6ab22bb on this PR. main's check goes green again once this PR merges.


Generated by Claude Code

@squid-protocol
squid-protocol merged commit 1806efb into main Sep 25, 2026
36 checks passed
@squid-protocol
squid-protocol deleted the claude/festive-fermat-kojuy7 branch September 25, 2026 15:43
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.

Kotlin func_start misses extension functions with a generic receiver (Collection<X>.name, fun <T> List<T>.name)

2 participants