From d152ff286f6ef2b25bd95bf97a429a1dc40ba4b5 Mon Sep 17 00:00:00 2001 From: Than McIntosh Date: Tue, 23 Apr 2019 12:38:36 -0400 Subject: [PATCH] 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/+/173440 Reviewed-by: Ian Lance Taylor --- src/go/internal/gccgoimporter/parser.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/go/internal/gccgoimporter/parser.go b/src/go/internal/gccgoimporter/parser.go index 5fd913c54a..64a4042a45 100644 --- a/src/go/internal/gccgoimporter/parser.go +++ b/src/go/internal/gccgoimporter/parser.go @@ -493,6 +493,7 @@ func (p *parser) parseNamedType(nlist []int) types.Type { // type alias if p.tok == '=' { p.next() + p.aliases[nlist[len(nlist)-1]] = name if obj != nil { // use the previously imported (canonical) type t := obj.Type() @@ -502,7 +503,6 @@ func (p *parser) parseNamedType(nlist []int) types.Type { } t := p.parseType(pkg, nlist...) obj = types.NewTypeName(token.NoPos, pkg, name, t) - p.aliases[nlist[len(nlist)-1]] = name scope.Insert(obj) return t } -- 2.48.1