mirror of
https://github.com/golang/go
synced 2024-11-22 09:34:54 -07:00
parent
7fce5ad011
commit
6e0767bb04
@ -569,6 +569,8 @@ func (t *StructType) NumField() int { return len(t.fields) }
|
||||
// Same memory layouts, different method sets.
|
||||
func toType(i interface{}) Type {
|
||||
switch v := i.(type) {
|
||||
case nil:
|
||||
return nil
|
||||
case *runtime.BoolType:
|
||||
return (*BoolType)(unsafe.Pointer(v))
|
||||
case *runtime.DotDotDotType:
|
||||
|
@ -906,7 +906,10 @@ func setiface(typ *InterfaceType, x *interface{}, addr addr)
|
||||
|
||||
// Set assigns x to v.
|
||||
func (v *InterfaceValue) Set(x Value) {
|
||||
i := x.Interface();
|
||||
var i interface{}
|
||||
if x != nil {
|
||||
i = x.Interface()
|
||||
}
|
||||
if !v.canSet {
|
||||
panic(cannotSet)
|
||||
}
|
||||
|
@ -108,5 +108,11 @@ func setiface(typ *byte, x *byte, ret *byte) {
|
||||
*(Eface*)ret = *(Eface*)x;
|
||||
return;
|
||||
}
|
||||
if(((Eface*)x)->type == nil) {
|
||||
// can assign nil to any interface
|
||||
((Iface*)ret)->tab = nil;
|
||||
((Iface*)ret)->data = nil;
|
||||
return;
|
||||
}
|
||||
ifaceE2I((InterfaceType*)gettype(typ), *(Eface*)x, (Iface*)ret);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user