mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
encoding/json: use reflect.TypeAssert
Updates #62121 Change-Id: Ic3c4fe84a5dacfd8270aba0d5dd59f83f0a9030f Reviewed-on: https://go-review.googlesource.com/c/go/+/701955 Reviewed-by: Mark Freeman <markfreeman@google.com> Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
4c20f7f15a
commit
e6605a1bcc
6 changed files with 30 additions and 27 deletions
|
|
@ -482,11 +482,11 @@ func indirect(v reflect.Value, decodingNull bool) (Unmarshaler, encoding.TextUnm
|
|||
v.Set(reflect.New(v.Type().Elem()))
|
||||
}
|
||||
if v.Type().NumMethod() > 0 && v.CanInterface() {
|
||||
if u, ok := v.Interface().(Unmarshaler); ok {
|
||||
if u, ok := reflect.TypeAssert[Unmarshaler](v); ok {
|
||||
return u, nil, reflect.Value{}
|
||||
}
|
||||
if !decodingNull {
|
||||
if u, ok := v.Interface().(encoding.TextUnmarshaler); ok {
|
||||
if u, ok := reflect.TypeAssert[encoding.TextUnmarshaler](v); ok {
|
||||
return nil, u, reflect.Value{}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue