compiler,reflect: NumMethods reports exported methods only

Fixes #3796
This commit is contained in:
Damian Gryski
2023-06-17 01:21:43 -07:00
committed by Ron Evans
parent ef72c5bb4e
commit acba0748f1
2 changed files with 22 additions and 13 deletions
+5 -5
View File
@@ -560,7 +560,7 @@ type methodStruct struct {
i int
}
func (m methodStruct) valueMethod1() int {
func (m methodStruct) ValueMethod1() int {
return m.i
}
@@ -568,11 +568,11 @@ func (m methodStruct) valueMethod2() int {
return m.i
}
func (m *methodStruct) pointerMethod1() int {
func (m *methodStruct) PointerMethod1() int {
return m.i
}
func (m *methodStruct) pointerMethod2() int {
func (m *methodStruct) PointerMethod2() int {
return m.i
}
@@ -582,12 +582,12 @@ func (m *methodStruct) pointerMethod3() int {
func TestTinyNumMethods(t *testing.T) {
refptrt := TypeOf(&methodStruct{})
if got, want := refptrt.NumMethod(), 2+3; got != want {
if got, want := refptrt.NumMethod(), 1+2; got != want {
t.Errorf("Pointer Methods=%v, want %v", got, want)
}
reft := refptrt.Elem()
if got, want := reft.NumMethod(), 2; got != want {
if got, want := reft.NumMethod(), 1; got != want {
t.Errorf("Value Methods=%v, want %v", got, want)
}
}