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 reflect: ensure correct scanning of return values 2018-09-29 20:25:24 +00:00
asm_amd64.s reflect: ensure correct scanning of return values 2018-09-29 20:25:24 +00:00
asm_arm.s reflect: ensure correct scanning of return values 2018-09-29 20:25:24 +00:00
asm_arm64.s reflect: ensure correct scanning of return values 2018-09-29 20:25:24 +00:00
asm_mips64x.s reflect: ensure correct scanning of return values 2018-09-29 20:25:24 +00:00
asm_mipsx.s reflect: ensure correct scanning of return values 2018-09-29 20:25:24 +00:00
asm_ppc64x.s reflect: ensure correct scanning of return values 2018-09-29 20:25:24 +00:00
asm_riscv64.s reflect: correct riscv64 assembly 2020-01-19 15:28:32 +00:00
asm_s390x.s reflect: fix s390x reflect method calls 2018-09-30 20:30:55 +00:00
asm_wasm.s all: rename WebAssembly instructions according to spec changes 2019-03-03 21:10:01 +00:00
deepequal.go reflect: remove depth from deepequal recursion 2020-08-17 22:05:16 +00:00
example_test.go reflect: add an example for Kind 2018-10-03 22:38:53 +00:00
export_test.go reflect: fix unsafe conversions reported by -d=checkptr 2019-10-22 18:09:15 +00:00
makefunc.go reflect: ensure correct scanning of return values 2018-09-29 20:25:24 +00:00
set_test.go reflect: define MyBuffer more locally in TestImplicitMapConversion 2018-04-18 12:47:39 +00:00
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