mirror of
https://github.com/golang/go
synced 2024-11-23 06:50:05 -07:00
0eb694e9c2
Given: type u struct{} func (u) M() {} type t struct { u; u2 u } var v = reflect.ValueOf(t{}) Package reflect allows: v.Method(0) // v.M v.Field(0).Method(0) // v.u.M but panics from: v.Field(1).Method(0) // v.u2.M because u2 is not an exported field. However, u is not an exported field either, so this is inconsistent. It seems like this behavior originates from #12367, where it was decided to allow traversing unexported embedded fields to be able to access their exported fields, since package reflect doesn't provide an alternative way to access promoted fields directly. But extending that logic to promoted *methods* was inappropriate, because package reflect's normal method handling logic already handles promoted methods correctly. This CL corrects that mistake. Fixes #38521. Change-Id: If65008965f35927b4e7927cddf8614695288eb19 Reviewed-on: https://go-review.googlesource.com/c/go/+/228902 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> |
||
---|---|---|
.. | ||
articles | ||
codewalk | ||
gopher | ||
play | ||
progs | ||
asm.html | ||
cmd.html | ||
contrib.html | ||
contribute.html | ||
debugging_with_gdb.html | ||
diagnostics.html | ||
editors.html | ||
effective_go.html | ||
gccgo_contribute.html | ||
gccgo_install.html | ||
go1.1.html | ||
go1.2.html | ||
go1.3.html | ||
go1.4.html | ||
go1.5.html | ||
go1.6.html | ||
go1.7.html | ||
go1.8.html | ||
go1.9.html | ||
go1.10.html | ||
go1.11.html | ||
go1.12.html | ||
go1.13.html | ||
go1.14.html | ||
go1.15.html | ||
go1.html | ||
go1compat.html | ||
go_faq.html | ||
go_mem.html | ||
go_spec.html | ||
go-logo-black.png | ||
go-logo-blue.png | ||
go-logo-white.png | ||
help.html | ||
ie.css | ||
install-source.html | ||
install.html | ||
share.png | ||
tos.html |