Commit 627f4d85 authored by Robert Griesemer's avatar Robert Griesemer

go/types: set up correct type with NewAlias

Change-Id: I4b035b3539c98e5b1442d1009d457cbc199b42ee
Reviewed-on: https://go-review.googlesource.com/32637Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
parent 5513f855
......@@ -219,11 +219,18 @@ func (*Func) isDependency() {} // a function may be a dependency of an initi
type Alias struct {
object
orig Object // aliased constant, type, variable, or function; never an alias
kind token.Token // token.CONST, token.TYPE, token.VAR, or token.FUNC (type-checking internal use only)
kind token.Token // token.CONST, token.TYPE, token.VAR, or token.FUNC (only needed during resolve phase)
}
func NewAlias(pos token.Pos, pkg *Package, name string, orig Object) *Alias {
return &Alias{object{pos: pos, pkg: pkg, name: name}, orig, token.ILLEGAL}
var typ Type = Typ[Invalid]
if orig != nil {
typ = orig.Type()
}
// No need to set a valid Alias.kind - that field is only used during identifier
// resolution (1st type-checker pass). We could store the field outside but it's
// easier to keep it here.
return &Alias{object{nil, pos, pkg, name, typ, 0, token.NoPos}, orig, token.ILLEGAL}
}
// Orig returns the aliased object, or nil if there was an error.
......
......@@ -276,6 +276,7 @@ func (check *Checker) collectObjects() {
case *ast.AliasSpec:
obj := NewAlias(s.Name.Pos(), pkg, s.Name.Name, nil)
obj.typ = nil // unresolved
obj.kind = d.Tok
check.declarePkgObj(s.Name, obj, &declInfo{file: fileScope, init: s.Orig})
......
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