reflect: an unnamed type has no PkgPath

The reflect package was returning a non-empty PkgPath for an unnamed
type with methods, such as a type whose methods have a pointer
receiver.

Fixes #16328.

Change-Id: I733e93981ebb5c5c108ef9b03bf5494930b93cf3
Reviewed-on: https://go-review.googlesource.com/24862
Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
Ian Lance Taylor 2016-07-11 22:34:30 -07:00
parent a84b18ac86
commit 1f4e68d92b
2 changed files with 5 additions and 0 deletions

View file

@ -876,6 +876,9 @@ func (t *rtype) MethodByName(name string) (m Method, ok bool) {
}
func (t *rtype) PkgPath() string {
if t.tflag&tflagNamed == 0 {
return ""
}
ut := t.uncommon()
if ut == nil {
return ""