case *Func:
// functions may be recursive - no need to track dependencies
check.funcDecl(obj, d)
- case *Alias:
- // aliases cannot be recursive - no need to track dependencies
- check.aliasDecl(obj, d)
+ // Alias-related code. Keep for now.
+ // case *Alias:
+ // // aliases cannot be recursive - no need to track dependencies
+ // check.aliasDecl(obj, d)
default:
unreachable()
}
// but it may be nil.
func original(obj Object) Object {
// an alias stands for the original object; use that one instead
- if alias, _ := obj.(*Alias); alias != nil {
+ if alias, _ := obj.(*disabledAlias); alias != nil {
obj = alias.orig
// aliases always refer to non-alias originals
- if _, ok := obj.(*Alias); ok {
+ if _, ok := obj.(*disabledAlias); ok {
panic("original is an alias")
}
}
return obj
}
-func (check *Checker) aliasDecl(obj *Alias, decl *declInfo) {
+func (check *Checker) aliasDecl(obj *disabledAlias, decl *declInfo) {
assert(obj.typ == nil)
// alias declarations cannot use iota
func (*Func) isDependency() {} // a function may be a dependency of an initialization expression
// An Alias represents a declared alias.
-type Alias struct {
+type disabledAlias 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 (only needed during resolve phase)
}
-func NewAlias(pos token.Pos, pkg *Package, name string, orig Object) *Alias {
+func disabledNewAlias(pos token.Pos, pkg *Package, name string, orig Object) *disabledAlias {
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}
+ return &disabledAlias{object{nil, pos, pkg, name, typ, 0, token.NoPos}, orig, token.ILLEGAL}
}
// 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 }
+func (obj *disabledAlias) disabledOrig() Object { return obj.orig }
// A Label represents a declared label.
type Label struct {
}
return
- case *Alias:
- buf.WriteString("alias")
+ // Alias-related code. Keep for now.
+ // case *Alias:
+ // buf.WriteString("alias")
case *Label:
buf.WriteString("label")
return buf.String()
}
-func (obj *PkgName) String() string { return ObjectString(obj, nil) }
-func (obj *Const) String() string { return ObjectString(obj, nil) }
-func (obj *TypeName) String() string { return ObjectString(obj, nil) }
-func (obj *Var) String() string { return ObjectString(obj, nil) }
-func (obj *Func) String() string { return ObjectString(obj, nil) }
-func (obj *Alias) String() string { return ObjectString(obj, nil) }
-func (obj *Label) String() string { return ObjectString(obj, nil) }
-func (obj *Builtin) String() string { return ObjectString(obj, nil) }
-func (obj *Nil) String() string { return ObjectString(obj, nil) }
+func (obj *PkgName) String() string { return ObjectString(obj, nil) }
+func (obj *Const) String() string { return ObjectString(obj, nil) }
+func (obj *TypeName) String() string { return ObjectString(obj, nil) }
+func (obj *Var) String() string { return ObjectString(obj, nil) }
+func (obj *Func) String() string { return ObjectString(obj, nil) }
+func (obj *disabledAlias) String() string { return ObjectString(obj, nil) }
+func (obj *Label) String() string { return ObjectString(obj, nil) }
+func (obj *Builtin) String() string { return ObjectString(obj, nil) }
+func (obj *Nil) String() string { return ObjectString(obj, nil) }
func writeFuncName(buf *bytes.Buffer, f *Func, qf Qualifier) {
if f.typ != nil {
check.declare(fileScope, nil, obj, token.NoPos)
}
- 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})
+ // Alias-related code. Keep for now.
+ // 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})
case *ast.ValueSpec:
switch d.Tok {
delete(check.unusedDotImports[scope], pkg)
}
+ // Alias-related code. Keep for now.
// An alias stands for the original object; use that one instead.
// TODO(gri) We should be able to factor out the Typ[Invalid] test.
- if alias, _ := obj.(*Alias); alias != nil {
- obj = original(obj)
- if obj == nil || typ == Typ[Invalid] {
- return
- }
- assert(typ == obj.Type())
- }
+ // if alias, _ := obj.(*Alias); alias != nil {
+ // obj = original(obj)
+ // if obj == nil || typ == Typ[Invalid] {
+ // return
+ // }
+ // assert(typ == obj.Type())
+ // }
switch obj := obj.(type) {
case *PkgName: