MakeFunc(typ, f).Call([]Value{ValueOf(10)})
}
+type UnExportedFirst int
+
+func (i UnExportedFirst) ΦExported() {}
+func (i UnExportedFirst) unexported() {}
+
+// Issue 21177
+func TestMethodByNameUnExportedFirst(t *testing.T) {
+ defer func() {
+ if recover() != nil {
+ t.Errorf("should not panic")
+ }
+ }()
+ typ := TypeOf(UnExportedFirst(0))
+ m, _ := typ.MethodByName("ΦExported")
+ if m.Name != "ΦExported" {
+ t.Errorf("got %s, expected ΦExported", m.Name)
+ }
+}
+
// Issue 18635 (method version).
type KeepMethodLive struct{}
return Method{}, false
}
utmethods := ut.methods()
+ var eidx int
for i := 0; i < int(ut.mcount); i++ {
p := utmethods[i]
pname := t.nameOff(p.name)
- if pname.isExported() && pname.name() == name {
- return t.Method(i), true
+ if pname.isExported() {
+ if pname.name() == name {
+ return t.Method(eidx), true
+ }
+ eidx++
}
}
return Method{}, false