runtime/internal/lib/reflect: fix Field closure kind to func
This commit is contained in:
@@ -39,4 +39,12 @@ func main() {
|
|||||||
panic(fmt.Sprintf("not func: %T", fn))
|
panic(fmt.Sprintf("not func: %T", fn))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
v := reflect.ValueOf(T{})
|
||||||
|
if v.Field(0).Kind() != reflect.Func {
|
||||||
|
panic("must func")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type T struct {
|
||||||
|
fn func(int)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -600,8 +600,13 @@ func (v Value) Field(i int) Value {
|
|||||||
field := &tt.Fields[i]
|
field := &tt.Fields[i]
|
||||||
typ := field.Typ
|
typ := field.Typ
|
||||||
|
|
||||||
|
// Check closure to func
|
||||||
|
kind := typ.Kind()
|
||||||
|
if typ.IsClosure() {
|
||||||
|
kind = abi.Func
|
||||||
|
}
|
||||||
// Inherit permission bits from v, but clear flagEmbedRO.
|
// Inherit permission bits from v, but clear flagEmbedRO.
|
||||||
fl := v.flag&(flagStickyRO|flagIndir|flagAddr) | flag(typ.Kind())
|
fl := v.flag&(flagStickyRO|flagIndir|flagAddr) | flag(kind)
|
||||||
// Using an unexported field forces flagRO.
|
// Using an unexported field forces flagRO.
|
||||||
if !field.Exported() {
|
if !field.Exported() {
|
||||||
if field.Embedded() {
|
if field.Embedded() {
|
||||||
|
|||||||
Reference in New Issue
Block a user