Commit 03eb4f4
feat(cha): extend hierarchy extraction to Kotlin/PHP/Swift/Scala + harden cross-file resolution
CHA was INERT for Kotlin, PHP, Swift, and Scala — they extract classes but
extractClassRelationships had no branch for them (the C# defect, x4: zero inheritance edges
-> zero override/dispatch edges). Added a branch for each (Kotlin/Swift via delegation/
inheritance specifiers; PHP splitting base_clause/extends vs class_interface_clause/implements;
Scala via extends_clause + a new getScalaParser). Ruby/Go already worked; C++ has a branch.
Real-repo dogfood (DesignPatternsPHP, kotlinx.coroutines) confirmed correct edges at scale
(PHP 71, Kotlin 157 override edges) AND surfaced two false-positive bugs, both fixed:
- Cross-file/cross-namespace same-name collision -> false override edge (two unrelated `Logger`/
`Formatter` interfaces in different PHP namespaces). Fixed in buildClassNodes: when a base name
is not same-file AND ambiguous, SKIP rather than global-first-match — false-negatives over
false-positives. (FQCN/namespace-aware resolution is the future enhancement.)
- Kotlin qualified supertype mis-captured: `Job : CoroutineContext.Element` matched the outer
`CoroutineContext` (a phantom from extension-function receivers), fabricating overrides. Fixed
by taking the supertype leaf name and skipping qualified (dotted) types; applied to Swift too.
Generic supertypes (`Segment<T>`) still resolve to `Segment`.
Test-covered the last unproven scenario: override propagation through the DB-backed lazy path
(bfsFromDB) — traversed by default, excluded under directResolvedOnly, matching buildAdjacency.
CHA hierarchy support now: TS/JS, Python, Java, C++, C#, Ruby, Go, Kotlin, PHP, Swift, Scala.
Tests +8; full suite green (3762). Decisions: bf52c392, d5967a48, 9d87726f.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 4b63359 commit 03eb4f4
5 files changed
Lines changed: 291 additions & 2 deletions
File tree
- openspec
- changes/archive/add-type-hierarchy-resolved-dispatch
- specs/analyzer
- src/core
- analyzer
- services/mcp-handlers
Lines changed: 30 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
68 | 98 | | |
69 | 99 | | |
70 | 100 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5553 | 5553 | | |
5554 | 5554 | | |
5555 | 5555 | | |
| 5556 | + | |
| 5557 | + | |
| 5558 | + | |
| 5559 | + | |
| 5560 | + | |
| 5561 | + | |
| 5562 | + | |
| 5563 | + | |
| 5564 | + | |
| 5565 | + | |
| 5566 | + | |
| 5567 | + | |
| 5568 | + | |
| 5569 | + | |
| 5570 | + | |
| 5571 | + | |
| 5572 | + | |
| 5573 | + | |
5556 | 5574 | | |
5557 | 5575 | | |
5558 | 5576 | | |
| |||
6020 | 6038 | | |
6021 | 6039 | | |
6022 | 6040 | | |
| 6041 | + | |
| 6042 | + | |
| 6043 | + | |
| 6044 | + | |
| 6045 | + | |
| 6046 | + | |
| 6047 | + | |
| 6048 | + | |
| 6049 | + | |
| 6050 | + | |
| 6051 | + | |
| 6052 | + | |
| 6053 | + | |
| 6054 | + | |
| 6055 | + | |
| 6056 | + | |
| 6057 | + | |
| 6058 | + | |
| 6059 | + | |
| 6060 | + | |
| 6061 | + | |
| 6062 | + | |
| 6063 | + | |
| 6064 | + | |
| 6065 | + | |
| 6066 | + | |
| 6067 | + | |
| 6068 | + | |
| 6069 | + | |
| 6070 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
459 | 459 | | |
460 | 460 | | |
461 | 461 | | |
| 462 | + | |
462 | 463 | | |
463 | 464 | | |
464 | 465 | | |
| |||
489 | 490 | | |
490 | 491 | | |
491 | 492 | | |
| 493 | + | |
492 | 494 | | |
493 | 495 | | |
494 | 496 | | |
| |||
599 | 601 | | |
600 | 602 | | |
601 | 603 | | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
602 | 616 | | |
603 | 617 | | |
604 | 618 | | |
| |||
2739 | 2753 | | |
2740 | 2754 | | |
2741 | 2755 | | |
| 2756 | + | |
| 2757 | + | |
| 2758 | + | |
| 2759 | + | |
| 2760 | + | |
| 2761 | + | |
| 2762 | + | |
| 2763 | + | |
| 2764 | + | |
| 2765 | + | |
| 2766 | + | |
| 2767 | + | |
| 2768 | + | |
| 2769 | + | |
| 2770 | + | |
| 2771 | + | |
| 2772 | + | |
| 2773 | + | |
| 2774 | + | |
| 2775 | + | |
| 2776 | + | |
| 2777 | + | |
| 2778 | + | |
| 2779 | + | |
| 2780 | + | |
| 2781 | + | |
| 2782 | + | |
| 2783 | + | |
| 2784 | + | |
| 2785 | + | |
| 2786 | + | |
| 2787 | + | |
| 2788 | + | |
| 2789 | + | |
| 2790 | + | |
| 2791 | + | |
| 2792 | + | |
| 2793 | + | |
| 2794 | + | |
| 2795 | + | |
| 2796 | + | |
| 2797 | + | |
| 2798 | + | |
| 2799 | + | |
| 2800 | + | |
| 2801 | + | |
| 2802 | + | |
| 2803 | + | |
| 2804 | + | |
| 2805 | + | |
| 2806 | + | |
| 2807 | + | |
| 2808 | + | |
| 2809 | + | |
| 2810 | + | |
| 2811 | + | |
| 2812 | + | |
| 2813 | + | |
| 2814 | + | |
| 2815 | + | |
| 2816 | + | |
| 2817 | + | |
| 2818 | + | |
| 2819 | + | |
| 2820 | + | |
| 2821 | + | |
| 2822 | + | |
| 2823 | + | |
| 2824 | + | |
| 2825 | + | |
| 2826 | + | |
| 2827 | + | |
| 2828 | + | |
| 2829 | + | |
| 2830 | + | |
| 2831 | + | |
| 2832 | + | |
| 2833 | + | |
| 2834 | + | |
| 2835 | + | |
| 2836 | + | |
| 2837 | + | |
| 2838 | + | |
| 2839 | + | |
| 2840 | + | |
| 2841 | + | |
2742 | 2842 | | |
2743 | 2843 | | |
2744 | 2844 | | |
| |||
2863 | 2963 | | |
2864 | 2964 | | |
2865 | 2965 | | |
| 2966 | + | |
2866 | 2967 | | |
| 2968 | + | |
2867 | 2969 | | |
2868 | 2970 | | |
2869 | | - | |
2870 | | - | |
| 2971 | + | |
| 2972 | + | |
| 2973 | + | |
| 2974 | + | |
| 2975 | + | |
| 2976 | + | |
| 2977 | + | |
| 2978 | + | |
| 2979 | + | |
| 2980 | + | |
| 2981 | + | |
2871 | 2982 | | |
2872 | 2983 | | |
2873 | 2984 | | |
| |||
0 commit comments