reflect,reflectlite: make IsRO/MakeRO package methods

Having them as methods on reflectlite.Value makes them
visible to the user.

Also move new functions out of all_test.go so it can stay
closer to upstream (except for comments).
This commit is contained in:
Damian Gryski
2026-06-30 09:26:55 -07:00
committed by Damian Gryski
parent 33ddee76db
commit 10224a4bf8
3 changed files with 22 additions and 12 deletions
+11 -4
View File
@@ -47,11 +47,18 @@ func (v Value) isExported() bool {
return v.flags&valueFlagExported != 0
}
func (v Value) IsRO() bool {
func (v Value) isRO() bool {
return v.flags&(valueFlagRO) != 0
}
func (v Value) MakeRO(ro bool) Value {
// These are package methods, not methods on Value, since the reflect.Value embeds a reflectlite.Value, so any
// methods added to reflectlite.Value are visible to the user.
func IsRO(v Value) bool {
return v.isRO()
}
func MakeRO(v Value, ro bool) Value {
if ro {
v.flags |= valueFlagRO
} else {
@@ -61,7 +68,7 @@ func (v Value) MakeRO(ro bool) Value {
}
func (v Value) checkRO() {
if v.IsRO() {
if v.isRO() {
panic("reflect: value is not settable")
}
}
@@ -306,7 +313,7 @@ func (v Value) IsValid() bool {
}
func (v Value) CanInterface() bool {
return v.isExported() && !v.IsRO()
return v.isExported() && !v.isRO()
}
func (v Value) CanAddr() bool {