mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
reflect: fix method indexing for non-ASCII exported methods
Currently, methods are sorted by name. This happens to guarantee that exported ASCII methods appear before non-exported ASCII methods, but this breaks down when Unicode method names are considered. Type.Method already accounts for this by always indexing into the slice returned by exportedMethods. This CL makes Value.Method do the same. Fixes #22073. Change-Id: I9bfc6bbfb7353e0bd3c439a15d1c3da60d16d209 Reviewed-on: https://go-review.googlesource.com/66770 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
parent
b3cae37464
commit
6f1724ff41
2 changed files with 22 additions and 6 deletions
|
|
@ -6405,3 +6405,19 @@ func TestIssue22031(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
type NonExportedFirst int
|
||||
|
||||
func (i NonExportedFirst) ΦExported() {}
|
||||
func (i NonExportedFirst) nonexported() int { panic("wrong") }
|
||||
|
||||
func TestIssue22073(t *testing.T) {
|
||||
m := ValueOf(NonExportedFirst(0)).Method(0)
|
||||
|
||||
if got := m.Type().NumOut(); got != 0 {
|
||||
t.Errorf("NumOut: got %v, want 0", got)
|
||||
}
|
||||
|
||||
// Shouldn't panic.
|
||||
m.Call(nil)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue