summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cmd/gc/reflect.c2
-rw-r--r--src/pkg/gob/decode.go2
-rw-r--r--src/pkg/reflect/type.go28
3 files changed, 14 insertions, 18 deletions
diff --git a/src/cmd/gc/reflect.c b/src/cmd/gc/reflect.c
index e62062360..563c74082 100644
--- a/src/cmd/gc/reflect.c
+++ b/src/cmd/gc/reflect.c
@@ -627,7 +627,7 @@ ok:
ot = duint32(s, ot, n);
for(t1=t->type; t1!=T; t1=t1->down) {
// ../../pkg/runtime/type.go:/structField
- if(t1->sym) {
+ if(t1->sym && !t1->embedded) {
ot = dgostringptr(s, ot, t1->sym->name);
if(exportname(t1->sym->name))
ot = dgostringptr(s, ot, nil);
diff --git a/src/pkg/gob/decode.go b/src/pkg/gob/decode.go
index 17afca607..4469089c4 100644
--- a/src/pkg/gob/decode.go
+++ b/src/pkg/gob/decode.go
@@ -666,7 +666,7 @@ func compileDec(wireId typeId, rt reflect.Type) (engine *decEngine, err os.Error
localField, present := srt.FieldByName(wireField.name);
ovfl := overflow(wireField.name);
// TODO(r): anonymous names
- if !present || localField.Anonymous {
+ if !present {
op, err := decIgnoreOpFor(wireField.id);
if err != nil {
return nil, err
diff --git a/src/pkg/reflect/type.go b/src/pkg/reflect/type.go
index 7e4914cc2..beb5b8947 100644
--- a/src/pkg/reflect/type.go
+++ b/src/pkg/reflect/type.go
@@ -477,7 +477,11 @@ func (t *StructType) Field(i int) (f StructField) {
if p.name != nil {
f.Name = *p.name;
} else {
- f.Name = f.Type.Name();
+ t := f.Type;
+ if pt, ok := t.(*PtrType); ok {
+ t = pt.Elem();
+ }
+ f.Name = t.Name();
f.Anonymous = true;
}
if p.pkgPath != nil {
@@ -487,28 +491,20 @@ func (t *StructType) Field(i int) (f StructField) {
f.Tag = *p.tag;
}
f.Offset = p.offset;
+ f.Index = i;
return;
}
// FieldByName returns the field with the provided name and a boolean to indicate
-// that the field was found..
+// that the field was found.
func (t *StructType) FieldByName(name string) (f StructField, present bool) {
for i, p := range t.fields {
- if p.name == nil || *p.name != name {
- continue;
- }
- f.Name = *p.name;
- f.Type = toType(*p.typ);
- if p.pkgPath != nil {
- f.PkgPath = *p.pkgPath;
- }
- if p.tag != nil {
- f.Tag = *p.tag;
+ ff := t.Field(i);
+ if ff.Name == name {
+ f = ff;
+ present = true;
+ break;
}
- f.Offset = p.offset;
- f.Index = i;
- present = true;
- break;
}
return;
}