]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile: split exported/non-exported methods for interface type
authorCuong Manh Le <cuong@orijtech.com>
Fri, 2 Oct 2020 18:23:47 +0000 (01:23 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Fri, 9 Oct 2020 02:14:32 +0000 (02:14 +0000)
commit8f26b57f9afc238bdecb9b7030bc2f4364093885
tree0b9f9dba3d2c38f61735db9faae6a0061db9f6cb
parentf8df205e74d5122c43f41923280451641e566ee2
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>
doc/go1.16.html
src/cmd/compile/internal/gc/reflect.go
src/internal/reflectlite/type.go
src/internal/reflectlite/value.go
src/reflect/all_test.go
src/reflect/type.go
src/reflect/value.go
src/runtime/alg.go
src/runtime/iface.go
src/runtime/mfinal.go
src/runtime/type.go