Commit 56c4bb6
jgstern-agent
feat(kotlin): detect extension functions and mark is_exported (WI-fuhav)
Kotlin extension functions (``fun Receiver.name() { }``) were
invisible to the dead-code-maybe BFS: the static call graph never
reaches them because nothing textually "calls" an extension — the
runtime dispatches based on receiver type. Spring-boot's
SpringApplicationExtensions.kt was the top WI-tubot prospector
example (8339 cross-language hits, dominated the top-uncategorized
list because ``with`` is a Kotlin stdlib keyword).
Detect extension functions by walking the function_declaration
children in order: a ``user_type`` child that appears BEFORE the
``identifier`` (name) field is the distinguishing marker. Plain
functions have no preceding receiver; class method declarations
use a different AST path via _get_enclosing_class and are
unaffected.
When detected:
- Set Symbol.is_exported=True (extension functions are inherently
part of the public API of their receiver type — something
external invokes them).
- Record the receiver type text under meta.extension_receiver for
future linker use (full receiver-typed dispatch resolution is a
separate follow-up item).
Combined with the WI-zimum --seeds exports mode, these symbols
now count as reachable via the public-API seed set in
dead-code-maybe.
New helper in kotlin.py:
- _extract_kotlin_receiver_type(func_node, source): walks children
in AST order, returning the user_type text when it precedes the
identifier, None otherwise.
Tests (3 in TestKotlinExtensionFunctions):
- detects_extension_function: fun SpringApplication.configure(...)
- plain_function_not_flagged: fun greet() is NOT flagged
- extension_function_on_generic_receiver: fun List<Int>.sumSafe()
Refs: WI-fuhav-rigah-mojit-fuvom-vohim-jokiv-tosuj-ponah
Related: WI-tubot prospector 2026-04-11, WI-zimum Phase 1+2
Signed-off-by: jgstern-agent <josh-agent@iterabloom.com>1 parent a37d112 commit 56c4bb6
4 files changed
Lines changed: 138 additions & 3 deletions
File tree
- .ci
- packages/hypergumbo-lang-mainstream
- src/hypergumbo_lang_mainstream
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
| 5 | + | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
Lines changed: 65 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
81 | 128 | | |
82 | 129 | | |
83 | 130 | | |
| |||
587 | 634 | | |
588 | 635 | | |
589 | 636 | | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
590 | 654 | | |
591 | 655 | | |
592 | 656 | | |
| |||
606 | 670 | | |
607 | 671 | | |
608 | 672 | | |
| 673 | + | |
609 | 674 | | |
610 | 675 | | |
611 | 676 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
78 | 146 | | |
79 | 147 | | |
80 | 148 | | |
| |||
0 commit comments