Commit d152ff28 authored by Than McIntosh's avatar Than McIntosh

go/internal/gccgoimporter: revise previous anonymous field fix.

Revise the fix for #31540 to take into account the possibility that we
may see an alias to a name that has already been installed into
package scope. This scenario is not possible to reproduce with the
current importer unit tests; changes to the harness to enable this
scenario will be added in a later CL.

Updates #31540.

Change-Id: Ie155d5e0b998604177a78471cba2413f57d40229
Reviewed-on: https://go-review.googlesource.com/c/go/+/173440Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 13d0af4e
...@@ -493,6 +493,7 @@ func (p *parser) parseNamedType(nlist []int) types.Type { ...@@ -493,6 +493,7 @@ func (p *parser) parseNamedType(nlist []int) types.Type {
// type alias // type alias
if p.tok == '=' { if p.tok == '=' {
p.next() p.next()
p.aliases[nlist[len(nlist)-1]] = name
if obj != nil { if obj != nil {
// use the previously imported (canonical) type // use the previously imported (canonical) type
t := obj.Type() t := obj.Type()
...@@ -502,7 +503,6 @@ func (p *parser) parseNamedType(nlist []int) types.Type { ...@@ -502,7 +503,6 @@ func (p *parser) parseNamedType(nlist []int) types.Type {
} }
t := p.parseType(pkg, nlist...) t := p.parseType(pkg, nlist...)
obj = types.NewTypeName(token.NoPos, pkg, name, t) obj = types.NewTypeName(token.NoPos, pkg, name, t)
p.aliases[nlist[len(nlist)-1]] = name
scope.Insert(obj) scope.Insert(obj)
return t return t
} }
......
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