Debian Codegraph @

gopls/internal/test/marker/testdata/implementation/issue68641.txt

raw
1 Regression test that Implementation(I) returns J even when I and J are
2 both interfaces; see issue #68641. Previously, interface/interface
3 matches were never reported.
4
5 However, the direction of the query is determined by the concreteness
6 of the query type: Implements on a.B, an interface, reports types that
7 are assignable to it, a.C; but Implements on concrete a.impl reports
8 only interface types to which it may be assigned, and there is no way
9 to query from interface B to find the (wider) interface A. (This would
10 be a useful feature of LSP though; see
11 https://github.com/microsoft/language-server-protocol/issues/2037.)
12
13 The test exercises both the local (intra-) and global (cross-package)
14 algorithms and checks that they are consistent.
15
16 -- go.mod --
17 module example.com
18 go 1.12
19
20 -- a/a.go --
21 package a
22
23 type A interface { //@ loc(aA, "A"), implementation("A", aB, aC, aimpl, bA, bB, bC, bimpl)
24 A() //@ loc(aAA, "A"), implementation("A", aimplA, bimplA, bAA)
25 }
26
27 type B interface { //@ loc(aB, "B"), implementation("B", aC, aimpl, bB, bC, bimpl)
28 A
29 B()
30 }
31
32 type C interface { //@ loc(aC, "C"), implementation("C", aimpl, bC, bimpl)
33 B
34 C()
35 }
36
37 type impl int //@ loc(aimpl, "impl"), implementation("impl", aA, aB, aC, bA, bB, bC)
38
39 func (impl) A() //@ loc(aimplA, "A")
40 func (impl) B()
41 func (impl) C()
42
43 -- b/b.go --
44 package b
45
46 type A interface { //@ loc(bA, "A"), implementation("A", aA, aB, aC, aimpl, bB, bC, bimpl)
47 A() //@ loc(bAA, "A")
48 }
49
50 type B interface { //@ loc(bB, "B"), implementation("B", aB, aC, aimpl, bC, bimpl)
51 A
52 B()
53 }
54
55 type C interface { //@ loc(bC, "C"), implementation("C", aC, aimpl, bimpl)
56 B
57 C()
58 }
59
60 type impl int //@ loc(bimpl, "impl"), implementation("impl", aA, aB, aC, bA, bB, bC)
61
62 func (impl) A() //@ loc(bimplA, "A")
63 func (impl) B()
64 func (impl) C()