cmd/compile: import/export of alias declarations

This CL completes support for alias declarations in the compiler.

Also:
- increased export format version
- updated various comments

For #16339.
Fixes #17487.

Change-Id: Ic6945fc44c0041771eaf9dcfe973f601d14de069
Reviewed-on: https://go-review.googlesource.com/32090
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Robert Griesemer 2016-10-25 14:09:18 -07:00
parent 81038d2e2b
commit 03d81b5ed9
11 changed files with 291 additions and 61 deletions

View file

@ -174,7 +174,11 @@ func (p *noder) aliasDecl(decl *syntax.AliasDecl) {
}
pkg.Used = true
// Resolve original entity
orig := oldname(restrictlookup(qident.Sel.Value, pkg.Name.Pkg))
if orig.Sym.Flags&SymAlias != 0 {
Fatalf("original %v marked as alias", orig.Sym)
}
// An alias declaration must not refer to package unsafe.
if orig.Sym.Pkg == unsafepkg {
@ -222,16 +226,16 @@ func (p *noder) aliasDecl(decl *syntax.AliasDecl) {
redeclare(asym, "in alias declaration")
return
}
asym.Flags |= SymAlias
asym.Def = orig
asym.Block = block
asym.Lastlineno = lineno
if exportname(asym.Name) {
yyerror("cannot export alias %v: not yet implemented", asym)
// TODO(gri) newname(asym) is only needed to satisfy exportsym
// (and indirectly, exportlist). We should be able to just
// collect the Syms, eventually.
// exportsym(newname(asym))
exportsym(newname(asym))
}
}