You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Pascal/Delphi: base classes are resolved by filename convention only (TFoo -> Foo.pas), so inheritance across differently-named units fragments into per-file stubs — and takes cross-file calls with it #5280
_pascal_resolve_class resolves a base class name to its defining file by naming convention only:
# graphify/extractors/resolution.py# Pascal convention: TFooBar is defined in FooBar.pasprefix=class_name[:1]
unit_name=class_name[1:] ifprefixin ("T", "I") elseclass_name
TXForm is looked for in XForm.pas. When the class lives in a unit with any other name — which is the norm in real Delphi, not the exception — resolution returns None and the extractor creates a private stub node in every inheriting file. An inheritance hierarchy that is one tree in the compiler arrives in the graph as hundreds of disconnected two-node fragments.
The uses clause, which is what actually determines where a name comes from, is not consulted.
Two TXForm nodes, and the call to the inherited Refresh produces no edge at all.
Why it compounds
resolve_pascal_inherited_calls walks the inherits chain to resolve a call to a method inherited from another file. A chain severed at its first link resolves almost nothing — so this one gap takes the cross-file call graph with it. That is the empty calls: [] above.
Measured on a real corpus
Delphi application, 895 units / 671 forms / 1.5M lines, scanned as one graph (12 195 inherits edges):
before
after a fix
inherits edges pointing at a stub
9 121
7 593
…of those, with the declaration present in the corpus
1 528
4
cross-file calls edges
1 601
2 363 (+48%)
"what inherits from TXForm?"
1 class
415 classes
The 7 593 that remain are genuinely external (IDispatch, IXMLNode/TXMLNode, RTL and generated type libraries) and correctly keep their stubs. The residual 4 are VCL names (TADOQuery, TMenuItem, …) that also happen to be declared in-corpus, where the ambiguity guard rightly refuses to guess.
Shape of the fix
A post-extraction resolver in the registry, running beforepascal_inherited_calls so that pass walks a repaired chain. A declared type is told apart from a stub structurally — the extractor emits contains from the enclosing module to everything it declares, and nothing contains a stub. The retarget requires a unique declaration, preferring one in a unit the inheriting file imports (imports edges), and leaves the stub alone when the name is ambiguous or absent.
One constraint worth recording: the pass must not change the length of all_nodes / all_edges. On an incremental rebuild the framework hands resolvers scratch lists and keeps only what was appended (_rl_edges[_e0:]), so a resolver that dedupes or removes in place shifts that slice and copies unrelated edges into the graph. Retargeting the edge dicts is safe — the scratch list holds the same objects — and duplicates are best avoided up front rather than cleaned up afterwards.
I have this working and would be glad to open a PR.
Activity
github-actions commentedon Nov 17, 2026
Thanks for opening this issue, @patrykseksymfonia. A maintainer will take a look soon.
If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.
To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.
fix(pascal): resolve base classes to their declaration, not by filename