Skip to content

Commit ab3c13b

Browse files
authored
Merge branch 'main' into fix/native-prototype-extraction-1421
2 parents 5e7bcbf + 326fb90 commit ab3c13b

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

src/domain/graph/builder/call-resolver.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ export function resolveByMethodOrGlobal(
131131
}
132132

133133
if (typeName) {
134-
const typed = lookup.byName(`${typeName}.${call.name}`).filter((n) => n.kind === 'method');
134+
const typed = lookup
135+
.byName(`${typeName}.${call.name}`)
136+
.filter((n) => n.kind === 'method' && computeConfidence(relPath, n.file, null) >= 0.5);
135137
if (typed.length > 0) return typed;
136138

137139
// Prototype alias: `Foo.prototype.bar = identifier` seeds typeMap['Foo.bar'] = { type: identifier }.

tests/unit/call-resolver.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,34 @@ describe('resolveByMethodOrGlobal — static receiver confidence filter (#1398)'
123123
});
124124
});
125125

126+
describe('resolveByMethodOrGlobal — typeName branch confidence filter (#1398)', () => {
127+
it('returns same-directory typed method target (confidence 0.7 >= 0.5)', () => {
128+
const target = { id: 3, file: 'app/Foo.cs', kind: 'method' };
129+
const lookup = makeLookup({ 'Foo.bar': [target] });
130+
// typeMap entry: 'f' -> 'Foo' (e.g. from `let f = new Foo()`)
131+
const result = resolveByMethodOrGlobal(
132+
lookup,
133+
{ name: 'bar', receiver: 'f' },
134+
'app/Main.cs',
135+
new Map([['f', 'Foo']]),
136+
);
137+
expect(result).toEqual([target]);
138+
});
139+
140+
it('filters out distant typed method target (confidence 0.3 < 0.5)', () => {
141+
const target = { id: 4, file: 'lib/util/Foo.cs', kind: 'method' };
142+
const lookup = makeLookup({ 'Foo.bar': [target] });
143+
// typeMap entry: 'f' -> 'Foo' — but the definition lives in a distant subtree
144+
const result = resolveByMethodOrGlobal(
145+
lookup,
146+
{ name: 'bar', receiver: 'f' },
147+
'app/main/Main.cs',
148+
new Map([['f', 'Foo']]),
149+
);
150+
expect(result).toEqual([]);
151+
});
152+
});
153+
126154
describe('resolveByMethodOrGlobal — bare-call JS/TS module-scope guard (#1407)', () => {
127155
// `flush()` inside `Processor.run` — no receiver, JS/TS file.
128156
// Must NOT resolve to `Processor.flush` (class-scoped lookup is incorrect for JS/TS).

0 commit comments

Comments
 (0)