mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 02:57:46 +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) {
|
||||
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() {
|
||||
|
||||
Reference in New Issue
Block a user