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>
diff --git a/go/analysis/passes/stdmethods/stdmethods.go b/go/analysis/passes/stdmethods/stdmethods.go
index 1c18dbc..b61c322 100644
--- a/go/analysis/passes/stdmethods/stdmethods.go
+++ b/go/analysis/passes/stdmethods/stdmethods.go
@@ -131,7 +131,7 @@
 			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 829c5b5..9833f8f 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) 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\)`
 }