Debian Codegraph @

gopls/internal/test/marker/testdata/quickfix/stubmethods/stuberrors.txt

raw
1 This test verifies two types of errors when generating interface method stubs:
2 1. adding method __ would conflict with (or shadow) existing field
3 2. method __ already exists but has the wrong type
4
5 -- go.mod --
6 module mod.com
7
8 go 1.22
9
10 -- wrong/type.go --
11 package wrongtype
12
13 type I interface {
14 Foo()
15 Bar()
16 }
17
18 type B struct {
19 *A
20 }
21
22 type A struct {}
23
24 func (a *A) Foo() {}
25 func (b *B) Foo(bool) {} // method Foo exists on B but has the wrong type
26
27 var _ I = (*B)(nil) //@quickfixerr(re"..B..nil.", re"missing method", "already exists but has the wrong type")
28
29 -- field/conflict.go --
30 package fieldconflict
31
32 type I interface {
33 Foo()
34 Bar()
35 }
36
37 type B struct {
38 *A
39 }
40
41 type A struct {
42 Bar int // implementing a method "Bar" would conflict with existing field "Bar"
43 }
44
45 func (a *A) Foo() {}
46 var _ I = (*B)(nil) //@quickfixerr(re"..B..nil.", re"is a field, not a method", "would conflict with (or shadow) existing field")
47