diff --git a/go/analysis/passes/stdmethods/stdmethods.go b/go/analysis/passes/stdmethods/stdmethods.go index 1c18dbc9..b61c3220 100644 --- a/go/analysis/passes/stdmethods/stdmethods.go +++ b/go/analysis/passes/stdmethods/stdmethods.go @@ -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 diff --git a/go/analysis/passes/stdmethods/testdata/src/a/a.go b/go/analysis/passes/stdmethods/testdata/src/a/a.go index 829c5b53..9833f8fd 100644 --- a/go/analysis/passes/stdmethods/testdata/src/a/a.go +++ b/go/analysis/passes/stdmethods/testdata/src/a/a.go @@ -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\)` }