go.tools/gcimporter: use imported package info for anonymous fields

The package of a struct field is independent of the type of the
struct field - the old code was technically not correct. That said,
it does not seem possible (or very difficult) to create a test case
because for exported anonymous fields that field package doesn't matter
(it's not needed for name identity), and non-exported anonymous fields
cannot be accessed from an imported package.

R=adonovan
CC=golang-codereviews
https://golang.org/cl/47560043
This commit is contained in:
Robert Griesemer 2014-01-03 11:37:20 -08:00
parent 6770b5cdca
commit df08273253
1 changed files with 1 additions and 3 deletions

View File

@ -463,9 +463,7 @@ func (p *parser) parseField() (*types.Var, string) {
pkg = nil
name = typ.Name()
case *types.Named:
obj := typ.Obj()
pkg = obj.Pkg() // TODO(gri) is this still correct?
name = obj.Name()
name = typ.Obj().Name()
default:
p.errorf("anonymous field expected")
}