diff options
Diffstat (limited to 'libgo/go/encoding/gob/type.go')
-rw-r--r-- | libgo/go/encoding/gob/type.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/libgo/go/encoding/gob/type.go b/libgo/go/encoding/gob/type.go index 0dd7a0a770e..a8ee2fa4a5a 100644 --- a/libgo/go/encoding/gob/type.go +++ b/libgo/go/encoding/gob/type.go @@ -749,12 +749,28 @@ func Register(value interface{}) { rt := reflect.TypeOf(value) name := rt.String() - // But for named types (or pointers to them), qualify with import path. + // But for named types (or pointers to them), qualify with import path (but see inner comment). // Dereference one pointer looking for a named type. star := "" if rt.Name() == "" { if pt := rt; pt.Kind() == reflect.Ptr { star = "*" + // NOTE: The following line should be rt = pt.Elem() to implement + // what the comment above claims, but fixing it would break compatibility + // with existing gobs. + // + // Given package p imported as "full/p" with these definitions: + // package p + // type T1 struct { ... } + // this table shows the intended and actual strings used by gob to + // name the types: + // + // Type Correct string Actual string + // + // T1 full/p.T1 full/p.T1 + // *T1 *full/p.T1 *p.T1 + // + // The missing full path cannot be fixed without breaking existing gob decoders. rt = pt } } |