The package of anonymous fields is the package in which they were
declared, not the package of the anonymous field's type. Was correct
before and incorrectly changed with https://golang.org/cl/18549.
Change-Id: I9fd5bfbe9d0498c8733b6ca7b134a85defe16113
Reviewed-on: https://go-review.googlesource.com/18596
Reviewed-by: Alan Donovan <adonovan@google.com>
// anonymous field - typ must be T or *T and T must be a type name
switch typ := deref(typ).(type) {
case *types.Basic: // basic types are named types
- pkg = nil
+ pkg = nil // objects defined in Universe scope have no package
name = typ.Name()
case *types.Named:
- obj := typ.Obj()
- pkg = obj.Pkg()
- name = obj.Name()
+ name = typ.Obj().Name()
default:
p.errorf("anonymous field expected")
}