mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/link, reflect: remove some method type data
Remove reflect type information for unexported methods that do not satisfy any interface in the program. Ideally the unexported method would not appear in the method list at all, but that is tricky because the slice is built by the compiler. Reduces binary size: cmd/go: 81KB (0.8%) jujud: 258KB (0.4%) For #6853. Change-Id: I25ef8df6907e9ac03b18689d584ea46e7d773043 Reviewed-on: https://go-review.googlesource.com/21033 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
c1892b9c4b
commit
44d3f89e99
3 changed files with 41 additions and 24 deletions
|
|
@ -2367,6 +2367,32 @@ func TestNestedMethods(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
type unexp struct{}
|
||||
|
||||
func (*unexp) f() (int32, int8) { return 7, 7 }
|
||||
func (*unexp) g() (int64, int8) { return 8, 8 }
|
||||
|
||||
func TestUnexportedMethods(t *testing.T) {
|
||||
_ = (interface {
|
||||
f() (int32, int8)
|
||||
})(new(unexp))
|
||||
|
||||
typ := TypeOf(new(unexp))
|
||||
|
||||
if typ.Method(0).Type == nil {
|
||||
t.Error("missing type for satisfied method 'f'")
|
||||
}
|
||||
if !typ.Method(0).Func.IsValid() {
|
||||
t.Error("missing func for satisfied method 'f'")
|
||||
}
|
||||
if typ.Method(1).Type != nil {
|
||||
t.Error("found type for unsatisfied method 'g'")
|
||||
}
|
||||
if typ.Method(1).Func.IsValid() {
|
||||
t.Error("found func for unsatisfied method 'g'")
|
||||
}
|
||||
}
|
||||
|
||||
type InnerInt struct {
|
||||
X int
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue