reflect: convert non-interface to interface in Set()

Этот коммит содержится в:
Damian Gryski 2023-03-11 16:03:38 -08:00 коммит произвёл Ron Evans
родитель c0f8f129c0
коммит 63c7a41337

Просмотреть файл

@ -910,6 +910,15 @@ func (v Value) Set(x Value) {
if !v.typecode.AssignableTo(x.typecode) {
panic("reflect: cannot set")
}
if v.typecode.Kind() == Interface && x.typecode.Kind() != Interface {
intf := composeInterface(unsafe.Pointer(x.typecode), x.value)
x = Value{
typecode: v.typecode,
value: unsafe.Pointer(&intf),
}
}
size := v.typecode.Size()
xptr := x.value
if size <= unsafe.Sizeof(uintptr(0)) && !x.isIndirect() {