1
0
mirror of https://github.com/golang/go synced 2024-11-23 19:20:03 -07:00

go/importer: revert incorrect change that slipped in prior CL

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>
This commit is contained in:
Robert Griesemer 2016-01-13 10:41:37 -08:00
parent 4a0eee2faa
commit 00c0a3a677

View File

@ -492,12 +492,10 @@ func (p *parser) parseField(parent *types.Package) (*types.Var, string) {
// anonymous field - typ must be T or *T and T must be a type name // anonymous field - typ must be T or *T and T must be a type name
switch typ := deref(typ).(type) { switch typ := deref(typ).(type) {
case *types.Basic: // basic types are named types case *types.Basic: // basic types are named types
pkg = nil pkg = nil // objects defined in Universe scope have no package
name = typ.Name() name = typ.Name()
case *types.Named: case *types.Named:
obj := typ.Obj() name = typ.Obj().Name()
pkg = obj.Pkg()
name = obj.Name()
default: default:
p.errorf("anonymous field expected") p.errorf("anonymous field expected")
} }