go/analysis/passes/tests: don't warn about missing method for each type
Only warn if the method is missing for all types. Fixes golang/go#30971 Change-Id: I94169ad3266f68ca20378a8dc5538aed2541a773 Reviewed-on: https://go-review.googlesource.com/c/tools/+/168803 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
e250d351ec
commit
6aabc1ca79
|
@ -1,10 +1,14 @@
|
|||
package b_x_test
|
||||
|
||||
import "b"
|
||||
import (
|
||||
"a"
|
||||
"b"
|
||||
)
|
||||
|
||||
func ExampleFoo_F() {
|
||||
var x b.Foo
|
||||
x.F()
|
||||
a.Foo()
|
||||
}
|
||||
|
||||
func ExampleFoo_G() { // want "ExampleFoo_G refers to unknown field or method: Foo.G"
|
||||
|
|
|
@ -153,9 +153,9 @@ func checkExample(pass *analysis.Pass, fn *ast.FuncDecl) {
|
|||
if obj, _, _ := types.LookupFieldOrMethod(obj.Type(), true, obj.Pkg(), mmbr); obj != nil {
|
||||
found = true
|
||||
}
|
||||
if !found {
|
||||
pass.Reportf(fn.Pos(), "%s refers to unknown field or method: %s.%s", fnName, ident, mmbr)
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
pass.Reportf(fn.Pos(), "%s refers to unknown field or method: %s.%s", fnName, ident, mmbr)
|
||||
}
|
||||
}
|
||||
if len(elems) == 3 && !isExampleSuffix(elems[2]) {
|
||||
|
|
Loading…
Reference in New Issue