reflect: Fix bug calling method on indirect value.

The gccgo-specific iword function was checking v.kind, but for
a method value that is always Func.  Fix to check v.typ.Kind()
instead.

From-SVN: r202670
This commit is contained in:
Ian Lance Taylor 2013-09-17 22:11:43 +00:00
parent 09d5094b2d
commit b15d794389

View File

@ -611,7 +611,13 @@ func methodReceiver(op string, v Value, methodIndex int) (t *rtype, fn unsafe.Po
}
fn = unsafe.Pointer(&m.tfn)
t = m.mtyp
rcvr = v.iword()
// Can't call iword here, because it checks v.kind,
// and that is always Func.
if v.flag&flagIndir != 0 && (v.typ.Kind() == Ptr || v.typ.Kind() == UnsafePointer) {
rcvr = loadIword(v.val, v.typ.size)
} else {
rcvr = iword(v.val)
}
}
return
}