]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: don't expose types.Alias kind field - only used by go/types
authorRobert Griesemer <gri@golang.org>
Mon, 31 Oct 2016 18:16:15 +0000 (11:16 -0700)
committerRobert Griesemer <gri@golang.org>
Mon, 31 Oct 2016 19:34:18 +0000 (19:34 +0000)
Change-Id: I8a28a88a655d9929f8641f71573dc01dc53be00f
Reviewed-on: https://go-review.googlesource.com/32443
Reviewed-by: Alan Donovan <adonovan@google.com>
src/go/internal/gcimporter/bimport.go
src/go/types/object.go
src/go/types/resolver.go

index 60e8c22594fc5b00de907387b01a7084a35e244b..2d6133a31b7905c0150737dbf6ac96e8651f8b0a 100644 (file)
@@ -264,7 +264,7 @@ func (p *importer) obj(tag int) {
        }
 
        if aliasName != "" {
-               p.declare(types.NewAlias(aliasPos, p.pkgList[0], aliasName, 0, obj))
+               p.declare(types.NewAlias(aliasPos, p.pkgList[0], aliasName, obj))
        }
 }
 
index 42f030df046a87e55b3a78ab81082c7f7b09cda8..ec3fe3d1704683ff561afd5b42d65eeab87951c7 100644 (file)
@@ -218,16 +218,17 @@ func (*Func) isDependency()     {} // a function may be a dependency of an initi
 // An Alias represents a declared alias.
 type Alias struct {
        object
-       kind token.Token // token.CONST, token.TYPE, token.VAR, or token.FUNC
-       orig Object      // aliased constant, type, variable, or function
+       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)
 }
 
-func NewAlias(pos token.Pos, pkg *Package, name string, kind token.Token, orig Object) *Alias {
-       return &Alias{object{pos: pos, pkg: pkg, name: name}, kind, orig}
+func NewAlias(pos token.Pos, pkg *Package, name string, orig Object) *Alias {
+       return &Alias{object{pos: pos, pkg: pkg, name: name}, orig, token.ILLEGAL}
 }
 
-func (obj *Alias) Kind() token.Token { return obj.kind }
-func (obj *Alias) Orig() Object      { return obj.orig }
+// Orig returns the aliased object, or nil if there was an error.
+// The returned object is never an Alias.
+func (obj *Alias) Orig() Object { return obj.orig }
 
 // A Label represents a declared label.
 type Label struct {
index b6a85fc02a32bf7fd74b93f9f307101570e08d98..12ef4ad779db54b147f5a007970cbd171c3319de 100644 (file)
@@ -275,7 +275,8 @@ func (check *Checker) collectObjects() {
                                                }
 
                                        case *ast.AliasSpec:
-                                               obj := NewAlias(s.Name.Pos(), pkg, s.Name.Name, d.Tok, nil)
+                                               obj := NewAlias(s.Name.Pos(), pkg, s.Name.Name, nil)
+                                               obj.kind = d.Tok
                                                check.declarePkgObj(s.Name, obj, &declInfo{file: fileScope, init: s.Orig})
 
                                        case *ast.ValueSpec: