stateify: Fix afterLoad not being called for root object
PiperOrigin-RevId: 327711264
This commit is contained in:
parent
3163aff866
commit
df48227099
|
@ -584,10 +584,12 @@ func (ds *decodeState) Load(obj reflect.Value) {
|
|||
})
|
||||
|
||||
// Create the root object.
|
||||
ds.objectsByID = append(ds.objectsByID, &objectDecodeState{
|
||||
rootOds := &objectDecodeState{
|
||||
id: 1,
|
||||
obj: obj,
|
||||
})
|
||||
}
|
||||
ds.objectsByID = append(ds.objectsByID, rootOds)
|
||||
ds.pending.PushBack(rootOds)
|
||||
|
||||
// Read the number of objects.
|
||||
lastID, object, err := ReadHeader(ds.r)
|
||||
|
|
|
@ -20,6 +20,14 @@ import (
|
|||
|
||||
func TestLoadHooks(t *testing.T) {
|
||||
runTestCases(t, false, "load-hooks", []interface{}{
|
||||
// Root object being a struct.
|
||||
afterLoadStruct{v: 1},
|
||||
valueLoadStruct{v: 1},
|
||||
genericContainer{v: &afterLoadStruct{v: 1}},
|
||||
genericContainer{v: &valueLoadStruct{v: 1}},
|
||||
sliceContainer{v: []interface{}{&afterLoadStruct{v: 1}}},
|
||||
sliceContainer{v: []interface{}{&valueLoadStruct{v: 1}}},
|
||||
// Root object being a pointer.
|
||||
&afterLoadStruct{v: 1},
|
||||
&valueLoadStruct{v: 1},
|
||||
&genericContainer{v: &afterLoadStruct{v: 1}},
|
||||
|
|
Loading…
Reference in New Issue