Commit 18f0e881 authored by Robert Griesemer's avatar Robert Griesemer

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: default avatarAlan Donovan <adonovan@google.com>
parent 322436b7
...@@ -278,11 +278,13 @@ func (p *importer) obj(tag int) { ...@@ -278,11 +278,13 @@ func (p *importer) obj(tag int) {
p.declare(types.NewFunc(pos, pkg, name, sig)) p.declare(types.NewFunc(pos, pkg, name, sig))
case aliasTag: case aliasTag:
aliasPos := p.pos() pos := p.pos()
aliasName := p.string() name := p.string()
pkg, name := p.qualifiedName() var orig types.Object
obj := pkg.Scope().Lookup(name) if pkg, name := p.qualifiedName(); pkg != nil {
p.declare(types.NewAlias(aliasPos, p.pkgList[0], aliasName, obj)) orig = pkg.Scope().Lookup(name)
}
p.declare(types.NewAlias(pos, p.pkgList[0], name, orig))
default: default:
errorf("unexpected object tag %d", tag) errorf("unexpected object tag %d", tag)
...@@ -343,7 +345,9 @@ var ( ...@@ -343,7 +345,9 @@ var (
func (p *importer) qualifiedName() (pkg *types.Package, name string) { func (p *importer) qualifiedName() (pkg *types.Package, name string) {
name = p.string() name = p.string()
pkg = p.pkg() if name != "" {
pkg = p.pkg()
}
return return
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment