go/src/reflect
Cuong Manh Le 8f26b57f9a cmd/compile: split exported/non-exported methods for interface type
Currently, mhdr/methods is emitted with the same len/cap. There's no way
to distinguish between exported and non-exported methods statically.

This CL splits mhdr/methods into two parts, use "len" for number of
exported methods, and "cap" for all methods. This fixes the bug in
issue #22075, which intends to return the number of exported methods but
currently return all methods.

Note that with this encoding, we still can access either
all/exported-only/non-exported-only methods:

	mhdr[:cap(mhdr)]          // all methods
	mhdr                      // exported methods
	mhdr[len(mhdr):cap(mhdr)] // non-exported methods

Thank to Matthew Dempsky (@mdempsky) for suggesting this encoding.

Fixes #22075

Change-Id: If662adb03ccff27407d55a5578a0ed05a15e7cdd
Reviewed-on: https://go-review.googlesource.com/c/go/+/259237
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-10-09 02:14:32 +00:00
..
all_test.go cmd/compile: split exported/non-exported methods for interface type 2020-10-09 02:14:32 +00:00
asm_386.s
asm_amd64.s
asm_arm.s
asm_arm64.s
asm_mips64x.s
asm_mipsx.s
asm_ppc64x.s
asm_riscv64.s reflect: correct riscv64 assembly 2020-01-19 15:28:32 +00:00
asm_s390x.s
asm_wasm.s
deepequal.go reflect: remove depth from deepequal recursion 2020-08-17 22:05:16 +00:00
example_test.go
export_test.go
makefunc.go
set_test.go
swapper.go internal/unsafeheader: consolidate stringHeader and sliceHeader declarations into an internal package 2020-05-01 02:31:29 +00:00
tostring_test.go
type.go cmd/compile: split exported/non-exported methods for interface type 2020-10-09 02:14:32 +00:00
value.go cmd/compile: split exported/non-exported methods for interface type 2020-10-09 02:14:32 +00:00