mirror of
https://github.com/colbymchenry/codegraph.git
synced 2026-10-23 06:50:54 +08:00
fix(js,ts): static and instance methods override only their own kind (#2813)
The override-dispatch pass (interface-impl) linked a base class's
method to every subclass method of the same name, so a static method
counted as overriding an instance one, or the reverse, though a call to
one never runs the other (issue #2761). TypeScript nodes recorded
static already, so there the pass alone was wrong. JavaScript nodes
never did: the extractor had no isStatic hook and the kernel answered
nothing for the JS variants, so a JS class's static s() and s() were
both stored as instance methods.
JavaScript members now record their own static keyword with the hook
TypeScript uses (hasStaticModifier, which also keeps a method named
static() an instance one), and the kernel gives the JS variants the
same answer, so both engines agree. The pass skips a JS/TS base and
override whose static flags differ; a static method still overrides a
static one, and an instance method an instance one.
Validation: the new test fails 5 of 10 on main 08478eea (JS and JSX
static flags in both engines, and the override pairs) and passes 10 of
10 on the fix. A/B against main on 20 repos: webpack's lib loses 15
edges, every one a cross-kind pair, such as Module's instance
deserialize(context) to the static deserialize(context) factories of
NormalModule and six other modules, or Module's static
getSourceBasicTypes(module) to RuntimeModule's instance
getSourceBasicTypes(); the same-kind pairs stay and no edge is added.
No other repo's edges change. Nodes change only in is_static, 0 to 1,
on 315 JavaScript static members, none in TypeScript or another
language; the flask and gin control dumps are byte-identical. Kernel
parity over the 20 TS/JS repos: 16,612 of 16,873 files byte-parity,
none with diffs, the rest deferred to wasm as before. Index time,
median of 3 interleaved runs on vite, nuxt, webdriverio, insomnia and
webpack: -1.1% total, within noise.
Fixes #2761
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
efb091ec2f
commit
68fcf2f1c7
@@ -42,7 +42,7 @@ impl Variant {
|
||||
}
|
||||
}
|
||||
/// TS-family (typescript/tsx): type annotations, interfaces, enums,
|
||||
/// aliases, visibility, isStatic. The JS family lacks all of those hooks.
|
||||
/// aliases, visibility. The JS family lacks all of those hooks.
|
||||
fn is_ts(self) -> bool {
|
||||
matches!(self, Variant::Typescript | Variant::Tsx)
|
||||
}
|
||||
@@ -1072,13 +1072,10 @@ impl<'t> Walker<'t> {
|
||||
self.has_keyword_child(node, "async")
|
||||
}
|
||||
|
||||
/// TS has an isStatic hook; JS does not (None = field absent).
|
||||
/// A member's own `static` keyword: the isStatic hook TS and JS share
|
||||
/// (hasStaticModifier, #2761).
|
||||
fn is_static(&self, node: Node) -> Option<bool> {
|
||||
if self.variant.is_ts() {
|
||||
Some(self.has_keyword_child(node, "static"))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
Some(self.has_keyword_child(node, "static"))
|
||||
}
|
||||
|
||||
fn is_const_decl(&self, node: Node) -> bool {
|
||||
|
||||
Reference in New Issue
Block a user