Commit f9e1f94
authored
feat(analysis): inter-procedural return-type propagation (Phase 8.2) (#1279)
* feat(analysis): inter-procedural return-type propagation (Phase 8.2)
Extends type tracking beyond single-function scope. The JS/TS extractor
now records each function's declared or inferred return type in a new
`returnTypeMap`, then propagates that information to variables assigned
from call expressions before call-edge resolution runs.
Intra-file: `const x = createUser()` resolves x's type when `createUser`
has a TS return annotation or a `return new Constructor()` body. Method
chains (`getService().getRepo()`) are resolved recursively up to three
hops with confidence decaying 0.1 per hop (1.0 → 0.9 → 0.8 → 0.7).
Cross-file: `build-edges.ts` collects unresolved call assignments from
each extractor output and propagates return types from imported files
before both the native and JS call-edge paths run, so both engines
benefit automatically.
Expected impact: +10–15 pp on caller coverage for factory patterns,
builder patterns, and method chains.
* fix(analysis): fix currentClass leak and annotation guard in extractReturnTypeMapWalk
- Pass null as currentClass when recursing into function_declaration and
method_definition bodies, preventing nested function declarations from
being stored under the enclosing class name (e.g. ClassName.innerFn)
- Fix annotation guard condition: `1.0 > existing.confidence` was always
true (since 1.0 is maximum confidence); replace with `existing.confidence < 1.0`
so the first annotation wins for duplicate function names
* fix(analysis): move cross-file propagation outside transaction, export penalty constant
- Move propagateReturnTypesAcrossFiles call to before computeEdgesTx opens,
avoiding partial in-memory typeMap mutations if the transaction rolls back
- Export PROPAGATION_HOP_PENALTY from javascript.ts and use it in build-edges.ts
instead of a hardcoded 0.1 literal
- Add TODO comment to typePropagationDepth config entry clarifying it is not yet
wired to MAX_PROPAGATION_DEPTH (planned for Phase 8.3)1 parent 5512efe commit f9e1f94
6 files changed
Lines changed: 466 additions & 13 deletions
File tree
- src
- domain/graph/builder/stages
- extractors
- infrastructure
- tests
- parsers
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
388 | 390 | | |
389 | 391 | | |
390 | 392 | | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
391 | 451 | | |
392 | 452 | | |
393 | 453 | | |
| |||
864 | 924 | | |
865 | 925 | | |
866 | 926 | | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
867 | 932 | | |
868 | 933 | | |
869 | 934 | | |
| |||
0 commit comments