fix(resolution): recognize union instantiation

This commit is contained in:
ctype_lab
2026-08-06 17:11:26 +09:00
parent ba58365c6f
commit e922563e05
3 changed files with 53 additions and 2 deletions
+5 -2
View File
@@ -1079,13 +1079,16 @@ export class ReferenceResolver {
}
// Promote "calls" to "instantiates" when the resolved target is a
// class/struct. Languages without a `new` keyword (Python, Ruby)
// class/struct/union. Languages without a `new` keyword (Python, Ruby)
// express instantiation as `Foo()` — extraction can't tell that
// apart from a function call without symbol info, but resolution
// can: if `Foo` resolves to a class, the call IS an instantiation.
if (kind === 'calls') {
const targetNode = this.queries.getNodeById(ref.targetNodeId);
if (targetNode && (targetNode.kind === 'class' || targetNode.kind === 'struct')) {
if (
targetNode &&
(targetNode.kind === 'class' || targetNode.kind === 'struct' || targetNode.kind === 'union')
) {
kind = 'instantiates';
}
}
+1
View File
@@ -2107,6 +2107,7 @@ function findBestMatch(
if (
candidate.kind === 'class' ||
candidate.kind === 'struct' ||
candidate.kind === 'union' ||
candidate.kind === 'interface'
) {
score += 25;