fix: resolve receiver for binary methods on non interface types

This commit is contained in:
Marc Vertes
2020-03-12 14:42:04 +01:00
committed by GitHub
parent 78bbcda1f8
commit 9b07e73b5e
4 changed files with 27 additions and 7 deletions

View File

@@ -871,13 +871,11 @@ func (t *itype) lookupMethod(name string) (*node, []int) {
}
// lookupBinMethod returns a method and a path to access a field in a struct object (the receiver)
func (t *itype) lookupBinMethod(name string) (reflect.Method, []int, bool, bool) {
var isPtr bool
func (t *itype) lookupBinMethod(name string) (m reflect.Method, index []int, isPtr bool, ok bool) {
if t.cat == ptrT {
return t.val.lookupBinMethod(name)
}
var index []int
m, ok := t.TypeOf().MethodByName(name)
m, ok = t.TypeOf().MethodByName(name)
if !ok {
m, ok = reflect.PtrTo(t.TypeOf()).MethodByName(name)
isPtr = ok