runtime/internal/lib/reflect: fix Field closure kind to func

This commit is contained in:
visualfc
2025-09-26 10:18:23 +08:00
parent 8959c83397
commit ccaf59ec62
2 changed files with 14 additions and 1 deletions

View File

@@ -600,8 +600,13 @@ func (v Value) Field(i int) Value {
field := &tt.Fields[i]
typ := field.Typ
// Check closure to func
kind := typ.Kind()
if typ.IsClosure() {
kind = abi.Func
}
// 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.
if !field.Exported() {
if field.Embedded() {