mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/link: check for reflect.Value.MethodByName explicitly
Currently we only check for reflect.Value.Method. And reflect.Value.MethodByName is covered since it calls reflect.Value.Method internally. But it is brittle to rely on implementation detail of the reflect package. Check for MethodByName explicitly. Change-Id: Ifa8920e997524003dade03abc4fb3c4e64723643 Reviewed-on: https://go-review.googlesource.com/c/go/+/228881 Run-TryBot: Cherry Zhang <cherryyz@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
a32262d462
commit
af9ab6b2e8
2 changed files with 5 additions and 3 deletions
|
|
@ -22,7 +22,8 @@ import (
|
|||
//
|
||||
// 1. direct call
|
||||
// 2. through a reachable interface type
|
||||
// 3. reflect.Value.Method, or reflect.Type.Method
|
||||
// 3. reflect.Value.Method (or MethodByName), or reflect.Type.Method
|
||||
// (or MethodByName)
|
||||
//
|
||||
// The first case is handled by the flood fill, a directly called method
|
||||
// is marked as reachable.
|
||||
|
|
@ -33,7 +34,7 @@ import (
|
|||
// as reachable. This is extremely conservative, but easy and correct.
|
||||
//
|
||||
// The third case is handled by looking to see if any of:
|
||||
// - reflect.Value.Method is reachable
|
||||
// - reflect.Value.Method or MethodByName is reachable
|
||||
// - reflect.Type.Method or MethodByName is called (through the
|
||||
// REFLECTMETHOD attribute marked by the compiler).
|
||||
// If any of these happen, all bets are off and all exported methods
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue