diff options
author | Felix Lange <fjl@twurst.com> | 2015-01-16 06:21:41 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-01-16 06:35:26 +0800 |
commit | fc92abec2cc6e27e7e56a6a05850ad4ebbf63d7e (patch) | |
tree | f8ba38e7c5ad3be52fc22c09600b619e1f968c53 /rlp/encode.go | |
parent | 29c46cdf3405d6462deb2cb5cef87b1b4fb2bdc7 (diff) | |
download | go-tangerine-fc92abec2cc6e27e7e56a6a05850ad4ebbf63d7e.tar.gz go-tangerine-fc92abec2cc6e27e7e56a6a05850ad4ebbf63d7e.tar.zst go-tangerine-fc92abec2cc6e27e7e56a6a05850ad4ebbf63d7e.zip |
rlp: allow encoding non-empty interface values
This needs to be supported because []someInterface does occur sometimes.
Funny enough, the fix involves changes to the decoder. makeDecoder
cannot return an error for non-empty interfaces anymore because the type
cache builds both decoder and writer. Do the check at 'runtime' instead.
Diffstat (limited to 'rlp/encode.go')
-rw-r--r-- | rlp/encode.go | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/rlp/encode.go b/rlp/encode.go index 689d25dd8..d80b66315 100644 --- a/rlp/encode.go +++ b/rlp/encode.go @@ -280,7 +280,6 @@ func (r *encReader) next() []byte { var ( encoderInterface = reflect.TypeOf(new(Encoder)).Elem() - emptyInterface = reflect.TypeOf(new(interface{})).Elem() big0 = big.NewInt(0) ) @@ -292,7 +291,7 @@ func makeWriter(typ reflect.Type) (writer, error) { return writeEncoder, nil case kind != reflect.Ptr && reflect.PtrTo(typ).Implements(encoderInterface): return writeEncoderNoPtr, nil - case typ == emptyInterface: + case kind == reflect.Interface: return writeInterface, nil case typ.AssignableTo(reflect.PtrTo(bigInt)): return writeBigIntPtr, nil |