}
}
}
+
+type NonExportedFirst int
+
+func (i NonExportedFirst) ΦExported() {}
+func (i NonExportedFirst) nonexported() int { panic("wrong") }
+
+func TestIssue22073(t *testing.T) {
+ m := ValueOf(NonExportedFirst(0)).Method(0)
+
+ if got := m.Type().NumOut(); got != 0 {
+ t.Errorf("NumOut: got %v, want 0", got)
+ }
+
+ // Shouldn't panic.
+ m.Call(nil)
+}
t = tt.typeOff(m.typ)
} else {
rcvrtype = v.typ
- ut := v.typ.uncommon()
- if ut == nil || uint(i) >= uint(ut.mcount) {
+ ms := v.typ.exportedMethods()
+ if uint(i) >= uint(len(ms)) {
panic("reflect: internal error: invalid method index")
}
- m := ut.methods()[i]
+ m := ms[i]
if !v.typ.nameOff(m.name).isExported() {
panic("reflect: " + op + " of unexported method")
}
return v.typ.typeOff(m.typ)
}
// Method on concrete type.
- ut := v.typ.uncommon()
- if ut == nil || uint(i) >= uint(ut.mcount) {
+ ms := v.typ.exportedMethods()
+ if uint(i) >= uint(len(ms)) {
panic("reflect: internal error: invalid method index")
}
- m := ut.methods()[i]
+ m := ms[i]
return v.typ.typeOff(m.mtyp)
}