Skip to content

Commit

Permalink
go/analysis/passes/tests: don't warn about missing method for each type
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ianlancetaylor committed Mar 22, 2019
1 parent e250d35 commit 6aabc1c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion go/analysis/passes/tests/testdata/src/b_x_test/b_test.go
@@ -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"
Expand Down
6 changes: 3 additions & 3 deletions go/analysis/passes/tests/tests.go
Expand Up @@ -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]) {
Expand Down

0 comments on commit 6aabc1c

Please sign in to comment.