Commit 6773cd3
jgstern-agent
feat(scala): recognize secondary constructors as kind=constructor (WI-rupum)
Scala secondary constructors (def this(args) = this(...)) were
being extracted as kind="method" by the function_definition handler
in scala.py. They surfaced as the top-ranked dead-code-maybe
candidates on Kafka (CachedPartition.this, KafkaConfig.this,
FullFetchContext.this, OffsetTruncationState.this, FetchManager.this
at cross_language_hits=6192) because nothing in the static call
graph textually reaches them — Scala's constructor semantics
dispatch secondary constructors via ``new ClassName(args)`` at
construction time, outside the textual call graph.
Fix: when the function_definition's identifier text is ``this`` AND
an enclosing class/object/trait is present, extract it as
kind="constructor" with full_name="<Type>.this". dead-code-maybe's
kind filter (``kind in ("function","method")``) now skips it
automatically. Also set is_exported=True as a secondary safety net
so the --seeds exports mode treats secondary constructors as
reachable if anything downstream looks at the flag.
Tests (3 in TestScalaSecondaryConstructor):
- secondary_constructor_kind_and_exported: two secondary ctors on
the same class get kind="constructor" and is_exported=True.
- secondary_constructor_not_marked_method: confirms the secondary
ctor is NOT in the method symbol list alongside real methods.
- top_level_this_not_constructor: plain top-level function is
unaffected (no enclosing type → no special case).
Refs: WI-rupum-dabar-lodad-rubij-bapad-biris-rarob-mufur
Related: WI-tubot prospector 2026-04-11, WI-zimum Phase 1+2
Signed-off-by: jgstern-agent <josh-agent@iterabloom.com>1 parent 56c4bb6 commit 6773cd3
4 files changed
Lines changed: 96 additions & 4 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 | | |
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
| 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: 22 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
357 | | - | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
358 | 372 | | |
359 | 373 | | |
360 | 374 | | |
| |||
374 | 388 | | |
375 | 389 | | |
376 | 390 | | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
377 | 397 | | |
378 | 398 | | |
379 | 399 | | |
| |||
392 | 412 | | |
393 | 413 | | |
394 | 414 | | |
| 415 | + | |
395 | 416 | | |
396 | 417 | | |
397 | 418 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 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 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
100 | 169 | | |
101 | 170 | | |
102 | 171 | | |
| |||
0 commit comments