Debian Codegraph @

gopls/internal/test/marker/testdata/references/issue58506.txt

raw
1 Regression test for 'references' bug golang/go#58506.
2
3 The 'references' query below, applied to method A.F, implicitly uses
4 the 'implementation' operation. The correct response includes two
5 references to B.F, one from package b and one from package d.
6 However, the incremental 'implementation' algorithm had a bug that
7 cause it to fail to report the reference from package b.
8
9 The reason was that the incremental implementation uses different
10 algorithms for the local and global cases (with disjoint results), and
11 that when it discovered that type A satisfies interface B and thus
12 that B.F must be included among the global search targets, the
13 implementation forgot to also search package b for local references
14 to B.F.
15
16 -- go.mod --
17 module example.com
18 go 1.18
19
20 -- a/a.go --
21 package a
22
23 type A int
24
25 func (A) F() {} //@loc(refa, "F"), refs("F", refa, refb, refd)
26
27 -- b/b.go --
28 package b
29
30 import (
31 "example.com/a"
32 "example.com/c"
33 )
34
35 type B interface{ F() }
36
37 var _ B = a.A(0)
38 var _ B = c.C(0)
39
40 var _ = B.F //@loc(refb, "F")
41
42 -- c/c.go --
43 package c
44
45 type C int
46
47 // Even though C.F is "rename coupled" to A.F by B.F,
48 // it should not be among the results.
49 func (C) F() {}
50
51 -- d/d.go --
52 package d
53
54 import "example.com/b"
55
56 var _ any = b.B.F //@loc(refd, "F")