mirror of
https://github.com/golang/go.git
synced 2026-06-27 03:11:23 +00:00
reflect: Value.Methods should panic at nil interface value
Change-Id: Iac3a162a93e4b8680902b282c8f8f77129ab91bf
GitHub-Last-Rev: b857486317
GitHub-Pull-Request: golang/go#78935
Reviewed-on: https://go-review.googlesource.com/c/go/+/770420
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
c5b875218f
commit
891f4a8711
1 changed files with 3 additions and 2 deletions
|
|
@ -2678,9 +2678,10 @@ func (v Value) Fields() iter.Seq2[StructField, Value] {
|
|||
// Calling this method will force the linker to retain all exported methods in all packages.
|
||||
// This may make the executable binary larger but will not affect execution time.
|
||||
func (v Value) Methods() iter.Seq2[Method, Value] {
|
||||
rtype := v.Type()
|
||||
n := v.NumMethod()
|
||||
return func(yield func(Method, Value) bool) {
|
||||
rtype := v.Type()
|
||||
for i := range v.NumMethod() {
|
||||
for i := range n {
|
||||
if !yield(rtype.Method(i), v.Method(i)) {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue