summaryrefslogtreecommitdiff
path: root/libgo/go/go/types/typexpr.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/go/types/typexpr.go')
-rw-r--r--libgo/go/go/types/typexpr.go25
1 files changed, 16 insertions, 9 deletions
diff --git a/libgo/go/go/types/typexpr.go b/libgo/go/go/types/typexpr.go
index 931b924712..ecc0a7da02 100644
--- a/libgo/go/go/types/typexpr.go
+++ b/libgo/go/go/types/typexpr.go
@@ -45,6 +45,17 @@ func (check *Checker) ident(x *operand, e *ast.Ident, def *Named, path []*TypeNa
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())
+ // }
+
switch obj := obj.(type) {
case *PkgName:
check.errorf(e.Pos(), "use of package %s not in selector", obj.name)
@@ -623,8 +634,7 @@ func (check *Checker) structType(styp *Struct, e *ast.StructType, path []*TypeNa
// current field typ and tag
var typ Type
var tag string
- // anonymous != nil indicates an anonymous field.
- add := func(field *ast.Field, ident *ast.Ident, anonymous *TypeName, pos token.Pos) {
+ add := func(field *ast.Field, ident *ast.Ident, anonymous bool, pos token.Pos) {
if tag != "" && tags == nil {
tags = make([]string, len(fields))
}
@@ -633,15 +643,12 @@ func (check *Checker) structType(styp *Struct, e *ast.StructType, path []*TypeNa
}
name := ident.Name
- fld := NewField(pos, check.pkg, name, typ, anonymous != nil)
+ fld := NewField(pos, check.pkg, name, typ, anonymous)
// spec: "Within a struct, non-blank field names must be unique."
if name == "_" || check.declareInSet(&fset, pos, fld) {
fields = append(fields, fld)
check.recordDef(ident, fld)
}
- if anonymous != nil {
- check.recordUse(ident, anonymous)
- }
}
for _, f := range list.List {
@@ -650,7 +657,7 @@ func (check *Checker) structType(styp *Struct, e *ast.StructType, path []*TypeNa
if len(f.Names) > 0 {
// named fields
for _, name := range f.Names {
- add(f, name, nil, name.Pos())
+ add(f, name, false, name.Pos())
}
} else {
// anonymous field
@@ -668,7 +675,7 @@ func (check *Checker) structType(styp *Struct, e *ast.StructType, path []*TypeNa
check.errorf(pos, "anonymous field type cannot be unsafe.Pointer")
continue
}
- add(f, name, Universe.Lookup(t.name).(*TypeName), pos)
+ add(f, name, true, pos)
case *Named:
// spec: "An embedded type must be specified as a type name
@@ -690,7 +697,7 @@ func (check *Checker) structType(styp *Struct, e *ast.StructType, path []*TypeNa
continue
}
}
- add(f, name, t.obj, pos)
+ add(f, name, true, pos)
default:
check.invalidAST(pos, "anonymous field type %s must be named", typ)