fix(extraction): land upstream declaration initializer walks (#1511) (#1802)

Squash danusha2345's PR #1511 at d282f9e8 onto main 8c9c4761,
preserving its nine non-merge commits and main's existing Unreleased notes.
Calls in Kotlin, Java, TS/JS, Scala, Rust and Python declaration initializers
now retain the owner established by the upstream regression expectations.
Include the upstream CFML, dynamic-dispatch summary and viewer follow-ups.

Linux fail-to-pass validation (Node 22.19.0, rebuilt dist and native kernel):
- Before: TS load belonged to file:app.ts; Python/Kotlin/Scala/Rust calls
  vanished; Java lost the field-lambda, anonymous override and eager calls.
- After: all six languages PASS; 12 native/WASM LF/CRLF parity checks PASS.
- Focused initializer regressions: 10 passed with CODEGRAPH_KERNEL=0 and
  10 passed with the kernel enabled; Kotlin's grammar fallback is recorded.
- Related regression suites: 879 passed, 1 skipped across 15 test files.
- Evidence: /workspace/cg-1510-repro/before and /workspace/cg-1510-repro/after
  (combined test output: after/vitest.log).

Fixes #1510
Supersedes #1511

Co-authored-by: Colby McHenry <colbymchenry@users.noreply.github.com>
Co-authored-by: danusha2345 <ewidusoc498@gmail.com>
This commit is contained in:
Colby Mchenry
2026-09-08 17:33:45 -05:00
committed by GitHub
co-authored by Colby McHenry danusha2345
parent 8c9c4761b0
commit 9181dd1ef3
25 changed files with 884 additions and 108 deletions
@@ -22,6 +22,15 @@ public class TortureService extends BaseService implements Runnable, AutoCloseab
protected int count = 0;
private final List<String> names;
int packagePrivate, secondDeclarator;
/** Field initializers — walked scoped to the field (#693). */
private final Runnable fieldLambda = () -> helper(RETRY_LIMITS);
private final Runnable fieldAnonClass = new Runnable() {
@Override
public void run() {
helper(RETRY_LIMITS);
}
};
private final Runnable fieldMethodRef = TortureService::compute;
/** Ctor javadoc. */
public TortureService(List<String> names) {
@@ -74,6 +74,11 @@ export default {
},
};
// Initializer walks attributed to the declared symbol (#693). A plain call
// leaked to the FILE node; a non-exported object literal was skipped outright.
const eagerConfig = loadConfig();
const handlerMap = { onSave: () => persist(eagerConfig), onLoad: loadConfig() };
const lazyList = [() => persist(eagerConfig)];
// --- CommonJS export assignments (#1675) -----------------------------------
exports.getItems = async (req, res) => { res.json(await findItems()); };
module.exports.deleteItem = function (req, res) { removeItem(req.params.id); res.end(); };
@@ -50,6 +50,13 @@ val topDelegated by lazy { WidgetK(1) }
val (destA, destB) = makePair()
val withGetter: Int
get() = 42
val initLambda: () -> Unit = { caller() }
val initSam = Runnable { caller() }
val initObject = object : Runnable {
override fun run() {
caller()
}
}
class WidgetK(val size: Int, private var name: String = defaultName()) {
val area: Int = size * size
@@ -265,3 +272,20 @@ fun labeledLambda() {
}
fun whereClause(): Int where Int : Comparable<Int> = 1
class AccessorK {
val sameLineGetter: Int get() = compute()
var sameLinePair: Int get() = compute()
set(v) { draw(v) }
}
class SiblingAccessorK {
var nextLine: Int = 0
get() = compute()
set(v) { draw(v) }
val (localA, localB) = makePair()
init {
val fromInit = compute()
register(fromInit)
}
}
@@ -48,6 +48,11 @@ def shadowed():
handlers = {"recv": target_cb}
callbacks = [target_cb, view]
# Initializer walks attributed to the assigned name (#693).
INIT_EAGER = helper()
INIT_LAMBDA = lambda: target_cb()
INIT_MAP = {"a": helper()}
init_a, init_b = helper(), view()
# --- call receivers (#1683) ---------------------------------------------------
def bucket_chains(d, k, v):
@@ -285,6 +285,11 @@ fn mount() {
routes![top_level_h];
// Initializer walks attributed to the declared symbol (#693).
const INIT_CONST: usize = compute_len();
static INIT_LAZY: Lazy<Cfg> = Lazy::new(|| build_cfg());
static INIT_ALIAS: fn() = free_fn;
pub union Reg {
pub raw: u32,
pub halves: [u16; 2],
@@ -175,3 +175,10 @@ package object utilpkg {
def pkgHelper(): Int = 1
val pkgShared = 2
}
class InitWalk {
val initLambda: () => Unit = () => helperCall()
val initDirect = helperCall()
lazy val initLazy = process(1)
val initAnon = new Runnable { def run(): Unit = helperCall() }
}