mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-24 14:29:08 +00:00
reflect: convert non-interface to interface in Set()
This commit is contained in:
@@ -910,6 +910,15 @@ func (v Value) Set(x Value) {
|
|||||||
if !v.typecode.AssignableTo(x.typecode) {
|
if !v.typecode.AssignableTo(x.typecode) {
|
||||||
panic("reflect: cannot set")
|
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()
|
size := v.typecode.Size()
|
||||||
xptr := x.value
|
xptr := x.value
|
||||||
if size <= unsafe.Sizeof(uintptr(0)) && !x.isIndirect() {
|
if size <= unsafe.Sizeof(uintptr(0)) && !x.isIndirect() {
|
||||||
|
|||||||
Reference in New Issue
Block a user