go/analysis/passes/stdmethods: show p.T not dir/p.T in diagnostic
Type.String prints named types using the complete package path: "dir/pkg.T" The notation used by canonicalMethod, and the cmd/vet/all whitelist, and the one users want to see, uses only the package name: "pkg.T". Change-Id: If2334a8cca1fb80e947cb105530b946a5a8dec7b Reviewed-on: https://go-review.googlesource.com/c/149597 Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
parent
4f7cb802ba
commit
2f5a1a7a23
|
@ -131,7 +131,7 @@ func canonicalMethod(pass *analysis.Pass, id *ast.Ident) {
|
|||
expectFmt += " (" + argjoin(expect.results) + ")"
|
||||
}
|
||||
|
||||
actual := sign.String()
|
||||
actual := types.TypeString(sign, (*types.Package).Name)
|
||||
actual = strings.TrimPrefix(actual, "func")
|
||||
actual = id.Name + actual
|
||||
|
||||
|
|
|
@ -4,7 +4,10 @@
|
|||
|
||||
package a
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type T int
|
||||
|
||||
|
@ -18,6 +21,9 @@ func (U) Format(byte) {} // no error: first parameter must be fmt.State to trigg
|
|||
|
||||
func (U) GobDecode() {} // want `should have signature GobDecode\(\[\]byte\) error`
|
||||
|
||||
// Test rendering of type names such as xml.Encoder in diagnostic.
|
||||
func (U) MarshalXML(*xml.Encoder) {} // want `method MarshalXML\(\*xml.Encoder\) should...`
|
||||
|
||||
type I interface {
|
||||
ReadByte() byte // want `should have signature ReadByte\(\) \(byte, error\)`
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue