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

go/internal/gcimporter: backport changes from x/tools/go/gcimporter15

See https://go-review.googlesource.com/32581.

This makes x/tools/go/gcimporter15/bimport.go a close copy again
and the importer more robust.

Change-Id: If96ad6acd611878b7dfa6a13d005d847ece82ab6
Reviewed-on: https://go-review.googlesource.com/32647
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
Robert Griesemer 2016-11-03 10:47:44 -07:00
parent 322436b78c
commit 18f0e88103

View File

@ -278,11 +278,13 @@ func (p *importer) obj(tag int) {
p.declare(types.NewFunc(pos, pkg, name, sig))
case aliasTag:
aliasPos := p.pos()
aliasName := p.string()
pkg, name := p.qualifiedName()
obj := pkg.Scope().Lookup(name)
p.declare(types.NewAlias(aliasPos, p.pkgList[0], aliasName, obj))
pos := p.pos()
name := p.string()
var orig types.Object
if pkg, name := p.qualifiedName(); pkg != nil {
orig = pkg.Scope().Lookup(name)
}
p.declare(types.NewAlias(pos, p.pkgList[0], name, orig))
default:
errorf("unexpected object tag %d", tag)
@ -343,7 +345,9 @@ var (
func (p *importer) qualifiedName() (pkg *types.Package, name string) {
name = p.string()
pkg = p.pkg()
if name != "" {
pkg = p.pkg()
}
return
}