From df08273253c094c25d93d75f475593b940e5823f Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Fri, 3 Jan 2014 11:37:20 -0800 Subject: [PATCH] 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 --- go/gcimporter/gcimporter.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/go/gcimporter/gcimporter.go b/go/gcimporter/gcimporter.go index 0812de7e..ac52ee76 100644 --- a/go/gcimporter/gcimporter.go +++ b/go/gcimporter/gcimporter.go @@ -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") }