mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.typealias] cmd/compile, go/types, go/importer: various alias related fixes
cmd/compile: - remove crud from prior alias implementation - better comments in places go/types: - fix TypeName.IsAlias predicate - more tests go/importer (go/internal/gcimporter15): - handle "@" format for anonymous fields using aliases (currently tested indirectly via x/tools/gcimporter15 tests) For #18130. Change-Id: I23a6d4e3a4c2a5c1ae589513da73fde7cad5f386 Reviewed-on: https://go-review.googlesource.com/35101 Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
49de5f0351
commit
f011e0c6c3
5 changed files with 53 additions and 72 deletions
|
|
@ -582,7 +582,7 @@ func (p *importer) field() *Field {
|
|||
|
||||
f := newField()
|
||||
if sym.Name == "" {
|
||||
// anonymous field - typ must be T or *T and T must be a type name
|
||||
// anonymous field: typ must be T or *T and T must be a type name
|
||||
s := typ.Sym
|
||||
if s == nil && typ.IsPtr() {
|
||||
s = typ.Elem().Sym // deref
|
||||
|
|
@ -590,6 +590,7 @@ func (p *importer) field() *Field {
|
|||
sym = sym.Pkg.Lookup(s.Name)
|
||||
f.Embedded = 1
|
||||
} else if sym.Flags&SymAlias != 0 {
|
||||
// anonymous field: we have an explicit name because it's an alias
|
||||
f.Embedded = 1
|
||||
}
|
||||
|
||||
|
|
@ -635,13 +636,13 @@ func (p *importer) fieldName() *Sym {
|
|||
var flag SymFlags
|
||||
switch name {
|
||||
case "":
|
||||
// field name is exported - nothing to do
|
||||
// 1) field name matches base type name and is exported: nothing to do
|
||||
case "?":
|
||||
// field name is not exported - need package
|
||||
// 2) field name matches base type name and is not exported: need package
|
||||
name = ""
|
||||
pkg = p.pkg()
|
||||
case "@":
|
||||
// field name doesn't match type name (alias)
|
||||
// 3) field name doesn't match base type name (alias name): need name and possibly package
|
||||
name = p.string()
|
||||
flag = SymAlias
|
||||
fallthrough
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue