|
5 | 5 | * one dot segment (e.g. 'Namespace.ClassName.method'), the same-class dispatch |
6 | 6 | * must use only the segment immediately before the method name ('ClassName'), |
7 | 7 | * not the full qualified prefix ('Namespace.ClassName'). |
| 8 | + * |
| 9 | + * Also covers the static receiver confidence filter (#1398): the direct qualified |
| 10 | + * method fallback must apply computeConfidence >= 0.5 to avoid false edges from |
| 11 | + * distant files in a polyglot project. |
8 | 12 | */ |
9 | 13 | import { describe, expect, it } from 'vitest'; |
10 | 14 | import type { CallNodeLookup } from '../../src/domain/graph/builder/call-resolver.js'; |
@@ -88,3 +92,29 @@ describe('resolveByMethodOrGlobal — same-class this-dispatch with qualified ca |
88 | 92 | expect(result).toEqual([]); |
89 | 93 | }); |
90 | 94 | }); |
| 95 | + |
| 96 | +describe('resolveByMethodOrGlobal — static receiver confidence filter (#1398)', () => { |
| 97 | + it('returns same-directory static target (confidence 0.7 >= 0.5)', () => { |
| 98 | + const target = { id: 1, file: 'app/Validators.cs', kind: 'method' }; |
| 99 | + const lookup = makeLookup({ 'Validators.IsValidEmail': [target] }); |
| 100 | + const result = resolveByMethodOrGlobal( |
| 101 | + lookup, |
| 102 | + { name: 'IsValidEmail', receiver: 'Validators' }, |
| 103 | + 'app/Program.cs', |
| 104 | + new Map(), |
| 105 | + ); |
| 106 | + expect(result).toEqual([target]); |
| 107 | + }); |
| 108 | + |
| 109 | + it('filters out distant static target (confidence 0.3 < 0.5)', () => { |
| 110 | + const target = { id: 2, file: 'lib/util/Validators.cs', kind: 'method' }; |
| 111 | + const lookup = makeLookup({ 'Validators.IsValidEmail': [target] }); |
| 112 | + const result = resolveByMethodOrGlobal( |
| 113 | + lookup, |
| 114 | + { name: 'IsValidEmail', receiver: 'Validators' }, |
| 115 | + 'app/main/Program.cs', |
| 116 | + new Map(), |
| 117 | + ); |
| 118 | + expect(result).toEqual([]); |
| 119 | + }); |
| 120 | +}); |
0 commit comments